public DateTime toUTCDateTime(final LocalDate localDate) { validateContext(); return ClockUtil.toUTCDateTime(localDate, getReferenceLocalTime(), getFixedOffsetTimeZone()); }
public DateTime toUTCDateTime(final LocalDate localDate) { validateContext(); return ClockUtil.toUTCDateTime(localDate, getReferenceLocalTime(), getFixedOffsetTimeZone()); }
/** * Create a DateTime object using the specified reference time and timezone * * @param localDate LocalDate to convert * @param referenceTime Reference local time * @param dateTimeZone Target timezone * @return DateTime representing the input localDate at the specified reference time, in UTC */ public static DateTime toUTCDateTime(final LocalDate localDate, final LocalTime referenceTime, final DateTimeZone dateTimeZone) { DateTime targetDateTime; try { targetDateTime = new DateTime(localDate.getYear(), localDate.getMonthOfYear(), localDate.getDayOfMonth(), referenceTime.getHourOfDay(), referenceTime.getMinuteOfHour(), referenceTime.getSecondOfMinute(), dateTimeZone); } catch (final IllegalInstantException e) { // DST gap (shouldn't happen when using fixed offset timezones) targetDateTime = localDate.toDateTimeAtStartOfDay(dateTimeZone); } return toUTCDateTime(targetDateTime); }