Example usage for org.joda.time DateTimeZone UTC

List of usage examples for org.joda.time DateTimeZone UTC

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone UTC.

Prototype

DateTimeZone UTC

To view the source code for org.joda.time DateTimeZone UTC.

Click Source Link

Document

The time zone for Universal Coordinated Time

Usage

From source file:com.ning.metrics.collector.processing.db.DatabaseFeedEventStorage.java

License:Apache License

@Override
public List<String> insert(final Collection<FeedEvent> feedEvents) {
    return dbi.withHandle(new HandleCallback<List<String>>() {

        @Override/*  w w w.  j  a va2s  . c o m*/
        public List<String> withHandle(Handle handle) throws Exception {
            final List<String> idList = Lists.newArrayListWithCapacity(feedEvents.size());
            PreparedBatch batch = handle.prepareBatch(
                    "insert into feed_events (id, channel, created_at, metadata, event, subscription_id) values (:id, :channel, :now, :metadata, :event, :subscription_id)");

            for (FeedEvent feedEvent : feedEvents) {
                String id = UUID.randomUUID().toString();
                idList.add(id);
                batch.bind("id", id).bind("channel", feedEvent.getChannel())
                        .bind("metadata", mapper.writeValueAsString(feedEvent.getMetadata()))
                        .bind("event", mapper.writeValueAsString(feedEvent.getEvent()))
                        .bind("now", DateTimeUtils.getInstantMillis(new DateTime(DateTimeZone.UTC)))
                        .bind("subscription_id", feedEvent.getSubscriptionId()).add();
            }

            batch.execute();

            return idList;
        }
    });
}

From source file:com.ning.metrics.collector.processing.db.model.CounterEventData.java

License:Apache License

@JsonCreator
public CounterEventData(@JsonProperty("uniqueIdentifier") String uniqueIdentifier,
        @JsonProperty("createdDate") DateTime createdTime,
        @JsonProperty("counters") Map<String, Integer> counters) {
    this.uniqueIdentifier = uniqueIdentifier;

    this.counters = Maps.newHashMap(counters);

    if (createdTime != null) {
        this.createdTime = createdTime;
    } else {//from  w w w  .ja  v  a  2  s .  c  o  m
        this.createdTime = new DateTime(DateTimeZone.UTC);
    }
}

From source file:com.ning.metrics.collector.processing.db.model.FeedEventData.java

License:Apache License

public DateTime getCreatedDate() {
    if (data.get(CREATED_DATE_KEY) != null) {
        try {/*w  ww  . ja v a2s  .co m*/
            return new DateTime(data.get(CREATED_DATE_KEY), DateTimeZone.UTC);
        } catch (Exception e) {
            return new DateTime(DateTimeZone.UTC);
        }
    }

    return new DateTime(DateTimeZone.UTC);
}

From source file:com.ning.metrics.collector.processing.quartz.CounterEventCleanUpJob.java

License:Apache License

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    log.info("Starting clean up of expired rolled up counters");
    DateTime toDateTime = new DateTime(DateTimeZone.UTC);

    int deletedRolledUpEvents = counterStorage.cleanExpiredDailyRolledUpCounters(
            toDateTime.minus(config.getRolledUpCounterStorageTimeout().getMillis()));
    log.info(String.format("Deleted %d rolledup events", deletedRolledUpEvents));
    log.info("Expired roll up counter event clean up done");
}

From source file:com.ning.metrics.meteo.publishers.ResourceListener.java

License:Apache License

@Override
public void update(EventBean[] newEvents, EventBean[] oldEvents) {
    if (newEvents != null) {
        for (EventBean newEvent : newEvents) {
            for (String attribute : newEvent.getEventType().getPropertyNames()) {
                add(attribute, new DateTime(DateTimeZone.UTC), newEvent.get(attribute));
            }/* ww w  .  j a v a  2  s.com*/
        }
    }
}

From source file:com.niroshpg.android.earthquakemonitor.Utility.java

License:Apache License

/**
 * Helper method to convert the database representation of the date into something to display
 * to users.  As classy and polished a user experience as "20140102" is, we can do better.
 *
 * @param context Context to use for resource localization
 * @param dateStr The db formatted date string, expected to be of the form specified
 *                in Utility.DATE_FORMAT
 * @return a user-friendly representation of the date.
 *//*from w  ww .j a  v a 2  s  .c  om*/
public static String getFriendlyDayString(Context context, String dateStr) {
    // The day string for earthquake events uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"

    Date todayDate = new Date();
    String todayStr = EarthQuakeDataContract.getDbDateString(todayDate);
    DateTime inputDateUTC = DateTimeFormat.forPattern(DATETIME_FORMAT).withZone(DateTimeZone.UTC)
            .parseDateTime(dateStr);

    // currentTimeZone.inDaylightTime()
    DateTime inputDateCurrentTZ = inputDateUTC
            .toDateTime(DateTimeZone.forOffsetMillis(currentTimeZone.getRawOffset()));

    // If the date we're building the String for is today's date, the format
    // is "Today, June 24"
    if (todayStr.equals(dateStr)) {
        String today = context.getString(R.string.today);
        int formatId = R.string.format_full_friendly_date;
        return String.format(context.getString(formatId, today, getFormattedMonthDay(context, dateStr)));
    } else {

        DateTimeFormatter shortenedDateTimeFormat = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss");
        return inputDateCurrentTZ.toString(shortenedDateTimeFormat);
        //            }
    }
}

From source file:com.nominanuda.lang.CronExpr.java

License:Apache License

/**
 * timezone is defaulted to UTC/*w w w.  ja va  2s  . c  o m*/
 */
public CronExpr(String cronExpression) throws IllegalArgumentException {
    this(cronExpression, DateTimeZone.UTC);
}

From source file:com.nominanuda.lang.DateTimeHelper.java

License:Apache License

public String toISO8601UtcSecs(long utcEpochMillis) {
    return toISO8601UtcSecs(new DateTime(utcEpochMillis, DateTimeZone.UTC));
}

From source file:com.nominanuda.lang.DateTimeHelper.java

License:Apache License

public String toISO8601UtcMillis(long utcEpochMillis) {
    return toISO8601UtcMillis(new DateTime(utcEpochMillis, DateTimeZone.UTC));
}

From source file:com.nominanuda.lang.DateTimeHelper.java

License:Apache License

public String toISO8601UtcDate(long utcEpochMillis) {
    return toISO8601UtcDate(new DateTime(utcEpochMillis, DateTimeZone.UTC));
}