Example usage for org.joda.time MutableDateTime millisOfSecond

List of usage examples for org.joda.time MutableDateTime millisOfSecond

Introduction

In this page you can find the example usage for org.joda.time MutableDateTime millisOfSecond.

Prototype

public Property millisOfSecond() 

Source Link

Document

Get the millis of second property

Usage

From source file:com.google.gerrit.server.config.ScheduleConfig.java

License:Apache License

private static long initialDelay(Config rc, String section, String subsection, String keyStartTime,
        DateTime now, long interval) {
    long delay = MISSING_CONFIG;
    String start = rc.getString(section, subsection, keyStartTime);
    try {/* w w  w.j a  v  a  2  s .com*/
        if (start != null) {
            DateTimeFormatter formatter;
            MutableDateTime startTime = now.toMutableDateTime();
            try {
                formatter = ISODateTimeFormat.hourMinute();
                LocalTime firstStartTime = formatter.parseLocalTime(start);
                startTime.hourOfDay().set(firstStartTime.getHourOfDay());
                startTime.minuteOfHour().set(firstStartTime.getMinuteOfHour());
            } catch (IllegalArgumentException e1) {
                formatter = DateTimeFormat.forPattern("E HH:mm").withLocale(Locale.US);
                LocalDateTime firstStartDateTime = formatter.parseLocalDateTime(start);
                startTime.dayOfWeek().set(firstStartDateTime.getDayOfWeek());
                startTime.hourOfDay().set(firstStartDateTime.getHourOfDay());
                startTime.minuteOfHour().set(firstStartDateTime.getMinuteOfHour());
            }
            startTime.secondOfMinute().set(0);
            startTime.millisOfSecond().set(0);
            long s = startTime.getMillis();
            long n = now.getMillis();
            delay = (s - n) % interval;
            if (delay <= 0) {
                delay += interval;
            }
        } else {
            log.info(MessageFormat.format("{0} schedule parameter \"{0}.{1}\" is not configured", section,
                    keyStartTime));
        }
    } catch (IllegalArgumentException e2) {
        log.error(MessageFormat.format("Invalid {0} schedule parameter \"{0}.{1}\"", section, keyStartTime),
                e2);
        delay = INVALID_CONFIG;
    }
    return delay;
}

From source file:com.xpn.xwiki.criteria.impl.PeriodFactory.java

License:Open Source License

private static MutableDateTime toHourStart(MutableDateTime mdt) {
    mdt.setMinuteOfHour(mdt.minuteOfHour().getMinimumValue());
    mdt.setSecondOfMinute(mdt.secondOfMinute().getMinimumValue());
    mdt.setMillisOfSecond(mdt.millisOfSecond().getMinimumValue());
    return mdt;/*from  w  w  w .  ja  va2s.c o m*/
}