List of usage examples for org.joda.time MutableDateTime MutableDateTime
public MutableDateTime(Object instant)
From source file:au.org.intersect.dms.instrument.harvester.CellRMtbParser.java
License:Open Source License
private String convertPropertyValue(String name, Object value, Map<String, Object> row) { if (types.containsKey(name)) { if ("date".equals(types.get(name))) { MutableDateTime date = new MutableDateTime(value); Object timeValue = row.get("Document Creation Time"); LOGGER.trace("Converting date. Day: {}, time: {}", value, timeValue); DateTime time = new DateTime(timeValue); date.setTime(time);//from w w w .ja v a2s .com LOGGER.trace("Date converted to: {}", date); return convertDate2UTC(date.toDateTime()); } } return value.toString(); }
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);//w w w.j av a 2 s. co m nextTime.secondOfDay().add(1); 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:ch.windmobile.server.mongo.MongoDataSource.java
License:Open Source License
static protected DateTime getExpirationDate(DateTime now, DateTime lastUpdate) { MutableDateTime expirationDate = new MutableDateTime(lastUpdate.getZone()); if (isSummerFrequency(now)) { expirationDate.setMillis(lastUpdate.getMillis() + 20 * 60 * 1000); if (expirationDate.getHourOfDay() >= 20) { expirationDate.addDays(1);//from w ww . ja v a 2s . c om expirationDate.setHourOfDay(8); expirationDate.setMinuteOfHour(0); expirationDate.setSecondOfMinute(0); } } else { expirationDate.setMillis(lastUpdate.getMillis() + 60 * 60 * 1000); if (expirationDate.getHourOfDay() >= 17) { expirationDate.addDays(1); expirationDate.setHourOfDay(9); expirationDate.setMinuteOfHour(0); expirationDate.setSecondOfMinute(0); } } return expirationDate.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);/* w ww . j ava2 s .c o m*/ if (frequency.compareTo(MINUTELY) >= 0) dateTime.setSecondOfMinute(0); 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.foundationdb.server.types.mcompat.mfuncs.MWeek.java
License:Open Source License
@Override protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {/*www . j a v a 2 s .co m*/ int date = inputs.get(0).getInt32(); long ymd[] = MDateAndTime.decodeDate(date); int mode = getMode(context, inputs); if (!MDateAndTime.isValidDateTime(ymd, ZeroFlag.YEAR) || mode < 0) { context.warnClient(new InvalidDateFormatException("date", Integer.toString(date))); output.putNull(); } else { output.putInt32( modes[(int) mode].getWeek(new MutableDateTime(DateTimeZone.forID(context.getCurrentTimezone())), (int) ymd[0], (int) ymd[1], (int) ymd[2])); } }
From source file:com.foundationdb.server.types.mcompat.mfuncs.MYearWeek.java
License:Open Source License
@Override protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {/*from w w w . ja v a2 s.co m*/ int date = inputs.get(0).getInt32(); long ymd[] = MDateAndTime.decodeDate(date); int mode = getMode(context, inputs); if (!MDateAndTime.isValidDateTime(ymd, ZeroFlag.YEAR) || mode < 0) { context.warnClient(new InvalidDateFormatException("Invalid DATE value ", date + "")); output.putNull(); } else { output.putInt32(modes[(int) mode].getYearWeek( new MutableDateTime(DateTimeZone.forID(context.getCurrentTimezone())), (int) ymd[0], (int) ymd[1], (int) ymd[2])); } }
From source file:com.graphaware.module.timetree.domain.TimeInstant.java
License:Open Source License
/** * Create an instant immediately following the current one, i.e. with its resolution unit incremented by 1. * * @return next instant.// ww w.j av a 2 s . c o m */ public TimeInstant next() { MutableDateTime time = new MutableDateTime(getTime()); time.add(getResolution().getDateTimeFieldType().getDurationType(), 1); return new TimeInstant(time.getMillis(), getTimezone(), getResolution()); }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static MutableDateTime getCurrentMutableDateTime() { return new MutableDateTime(PDTConfig.getDefaultChronology()); }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static MutableDateTime getCurrentMutableDateTimeUTC() { return new MutableDateTime(PDTConfig.getDefaultChronologyUTC()); }
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);/*from w ww.ja va2 s.c o m*/ nextTime.secondOfDay().add(1); 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(); }