/** * Get this object as a DateTime using ISOChronology in the default zone. * This method is identical to <code>toDateTime()</code>. * <p> * This method returns a DateTime object in the default zone. * This differs from the similarly named method on DateTime, DateMidnight * or MutableDateTime which retains the time zone. The difference is * because Instant really represents a time <i>without</i> a zone, * thus calling this method we really have no zone to 'retain' and * hence expect to switch to the default zone. * <p> * This method is deprecated because it is a duplicate of {@link #toDateTime()}. * However, removing it would cause the superclass implementation to be used, * which would create silent bugs in any caller depending on this implementation. * As such, the method itself is not currently planned to be removed. * <p> * This method definition preserves compatibility with earlier versions * of Joda-Time. * * @return a DateTime using the same millis with ISOChronology * @deprecated Use toDateTime() as it is identical */ @Deprecated public DateTime toDateTimeISO() { return toDateTime(); }
/** * Get this object as a DateTime using ISOChronology in the default zone. * This method is identical to <code>toDateTime()</code>. * <p> * This method returns a DateTime object in the default zone. * This differs from the similarly named method on DateTime, DateMidnight * or MutableDateTime which retains the time zone. The difference is * because Instant really represents a time <i>without</i> a zone, * thus calling this method we really have no zone to 'retain' and * hence expect to switch to the default zone. * <p> * This method is deprecated because it is a duplicate of {@link #toDateTime()}. * However, removing it would cause the superclass implementation to be used, * which would create silent bugs in any caller depending on this implementation. * As such, the method itself is not currently planned to be removed. * <p> * This method definition preserves compatibility with earlier versions * of Joda-Time. * * @return a DateTime using the same millis with ISOChronology * @deprecated Use toDateTime() as it is identical */ @Deprecated public DateTime toDateTimeISO() { return toDateTime(); }
/** * Get this object as a DateTime using ISOChronology in the default zone. * This method is identical to <code>toDateTime()</code>. * <p> * This method returns a DateTime object in the default zone. * This differs from the similarly named method on DateTime, DateMidnight * or MutableDateTime which retains the time zone. The difference is * because Instant really represents a time <i>without</i> a zone, * thus calling this method we really have no zone to 'retain' and * hence expect to switch to the default zone. * <p> * This method is deprecated because it is a duplicate of {@link #toDateTime()}. * However, removing it would cause the superclass implementation to be used, * which would create silent bugs in any caller depending on this implementation. * As such, the method itself is not currently planned to be removed. * <p> * This method definition preserves compatibility with earlier versions * of Joda-Time. * * @return a DateTime using the same millis with ISOChronology * @deprecated Use toDateTime() as it is identical */ @Deprecated public DateTime toDateTimeISO() { return toDateTime(); }
public DateTime fromNonNullString(String s) { return new Instant(s).toDateTime(DateTimeZone.UTC); }
public DateTime fromNonNullValue(Long value) { return new Instant(value).toDateTime(DateTimeZone.UTC); }
/** * Creates a new {@code TimeInstant}. * * @param instant the instant */ public TimeInstant(Instant instant) { this(instant != null ? instant.toDateTime() : null, 0, null); }
Instant instant = Instant.now(); DateTimeZone zone = DateTimeZone.getDefault(); LocalDate date = instant.toDateTime(zone).toLocalDate();
/** * Zone to use for input and output */ private static final DateTimeZone ZONE = DateTimeZone.forId("Europe/London"); /** * Adds a number of days specified to the instant in time specified. * * @param instant - the date to be added to * @param numberOfDaysToAdd - the number of days to be added to the instant specified * @return an instant that has been incremented by the number of days specified */ public static Instant addNumberOfDaysToInstant(final Instant instant, final int numberOfDaysToAdd) { return instant.toDateTime(ZONE).withFieldAdded(DurationFieldType.days(), numberOfDaysToAdd).toInstant(); }
@Override public DateTime extractDatumDateTime(final Breadcrumb domainObject) { return domainObject.getProcessingTimestamp().toDateTime(); } }
@Override public DateTime extractDatumDateTime(final MyDatum domainObject) { return domainObject.getTimestamp().toDateTime(); } }
@Override public DateTime extractDatumDateTime(final MyDatum domainObject) { return domainObject.getTimestamp().toDateTime(); } }
public DateTime fromNonNullValue(Long value) { return new Instant(value).toDateTime(DateTimeZone.UTC); }
public DateTime fromNonNullString(String s) { return new Instant(s).toDateTime(DateTimeZone.UTC); }
// 1 month 5d 22h 35m 39s Period period = new Period(0, 1, 0, 5, 22, 35, 39, 0); Instant start = new Instant(); // current time => 2011-03-17T22:24:01.848+01:00 Duration dura = new Duration(start, start.toDateTime().plus(period)); Period period2 = new Period(dura).normalizedStandard(PeriodType.dayTime()); // => 36d 21h 35m 39s
/** * Converts an {@code Instant} object to an API date time in the time zone * supplied. */ public T toDateTime(Instant instant, String timeZoneId) { return toDateTime( instant.toDateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId)))); }
/** * Converts an {@code Instant} object to an API date time in the time zone * supplied. */ public T toDateTime(Instant instant, String timeZoneId) { return toDateTime( instant.toDateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId)))); }
@Override public DateTime extractDatumDateTime(final SampleDomainClass domainObject) { return domainObject.getEventTimestamp().toDateTime(); } }
protected Instant startOfDay () { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); return start.toDateTime(DateTimeZone.UTC).withHourOfDay(0).toInstant(); }
protected Instant lastSunday () { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); return start.toDateTime(DateTimeZone.UTC) .withDayOfWeek(1).withHourOfDay(0).toInstant(); }
protected Instant nextStartOfDay () { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); return start.toDateTime(DateTimeZone.UTC) .withHourOfDay(0).toInstant().plus(TimeService.DAY); }