List of usage examples for org.joda.time MutableDateTime setMillisOfSecond
public void setMillisOfSecond(final int millisOfSecond)
From source file:br.com.centralit.evm.citsmartevm.util.CronExpression.java
License:Apache License
public DateTime nextTimeAfter(DateTime afterTime) { MutableDateTime nextTime = new MutableDateTime(afterTime); nextTime.setMillisOfSecond(0); nextTime.secondOfDay().add(1);//from w w w . ja v a 2 s . c om while (true) { // day of week while (true) { // month while (true) { // day of month while (true) { // hour while (true) { // minute while (true) { // second if (secondField.matches(nextTime.getSecondOfMinute())) { break; } nextTime.secondOfDay().add(1); } if (minuteField.matches(nextTime.getMinuteOfHour())) { break; } nextTime.minuteOfDay().add(1); nextTime.secondOfMinute().set(0); } if (hourField.matches(nextTime.getHourOfDay())) { break; } nextTime.hourOfDay().add(1); nextTime.minuteOfHour().set(0); nextTime.secondOfMinute().set(0); } if (dayOfMonthField.matches(new LocalDate(nextTime))) { break; } nextTime.addDays(1); nextTime.setTime(0, 0, 0, 0); } if (monthField.matches(nextTime.getMonthOfYear())) { break; } nextTime.addMonths(1); nextTime.setDayOfMonth(1); nextTime.setTime(0, 0, 0, 0); } if (dayOfWeekField.matches(new LocalDate(nextTime))) { break; } nextTime.addDays(1); nextTime.setTime(0, 0, 0, 0); } return nextTime.toDateTime(); }
From source file:com.carmatech.cassandra.ShardingFrequency.java
License:Apache License
public static long calculateBucket(final long timestamp, final ShardingFrequency frequency) { final MutableDateTime dateTime = new MutableDateTime(timestamp); if (frequency.compareTo(SECONDLY) >= 0) dateTime.setMillisOfSecond(0); if (frequency.compareTo(MINUTELY) >= 0) dateTime.setSecondOfMinute(0);//from www .j a va2 s . c o m if (frequency.compareTo(HOURLY) >= 0) dateTime.setMinuteOfHour(0); if (frequency.compareTo(DAILY) >= 0) dateTime.setHourOfDay(0); if (frequency.compareTo(WEEKLY) >= 0) dateTime.setDayOfWeek(1); if (frequency.compareTo(MONTHLY) >= 0) dateTime.setDayOfMonth(1); return dateTime.getMillis(); }
From source file:com.huffingtonpost.chronos.util.CronExpression.java
License:Apache License
@CoverageIgnore public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) { MutableDateTime nextTime = new MutableDateTime(afterTime); nextTime.setMillisOfSecond(0); nextTime.secondOfDay().add(1);/*from ww w . j a va2s .c o m*/ while (true) { // day of week while (true) { // month while (true) { // day of month while (true) { // hour while (true) { // minute while (true) { // second if (secondField.matches(nextTime.getSecondOfMinute())) { break; } nextTime.secondOfDay().add(1); } if (minuteField.matches(nextTime.getMinuteOfHour())) { break; } nextTime.minuteOfDay().add(1); nextTime.secondOfMinute().set(0); } if (hourField.matches(nextTime.getHourOfDay())) { break; } nextTime.hourOfDay().add(1); nextTime.minuteOfHour().set(0); nextTime.secondOfMinute().set(0); } if (dayOfMonthField.matches(new LocalDate(nextTime))) { break; } nextTime.addDays(1); nextTime.setTime(0, 0, 0, 0); checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier); } if (monthField.matches(nextTime.getMonthOfYear())) { break; } nextTime.addMonths(1); nextTime.setDayOfMonth(1); nextTime.setTime(0, 0, 0, 0); checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier); } if (dayOfWeekField.matches(new LocalDate(nextTime))) { break; } nextTime.addDays(1); nextTime.setTime(0, 0, 0, 0); checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier); } return nextTime.toDateTime(); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToMinute(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0); result.setSecondOfMinute(0);/*www .jav a 2s. com*/ return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToHour(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0); result.setSecondOfMinute(0);/*from w w w . j a va 2s .com*/ result.setMinuteOfHour(0); return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToDay(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0); result.setSecondOfMinute(0);//from ww w .j ava 2 s.c om result.setMinuteOfHour(0); result.setHourOfDay(0); return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToMonth(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0); result.setSecondOfMinute(0);/*from w ww .ja va 2 s .c o m*/ result.setMinuteOfHour(0); result.setHourOfDay(0); result.setDayOfMonth(1); return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToWeek(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0); result.setSecondOfMinute(0);/* w w w. j a v a2 s .com*/ result.setMinuteOfHour(0); result.setHourOfDay(0); result.setHourOfDay(0); if (time.getDayOfWeek() != 7) { result.setDayOfWeek(1); result.add(Days.ONE.multipliedBy(-1)); } return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToYear(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0); result.setSecondOfMinute(0);/*from w ww . j av a 2 s. co m*/ result.setMinuteOfHour(0); result.setHourOfDay(0); result.setDayOfMonth(1); result.setMonthOfYear(1); return new DateTime(result); }
From source file:com.ning.metrics.serialization.writer.EventRate.java
License:Apache License
public DateTime truncateToSecond(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0); return new DateTime(result); }