/** * Returns a copy of this datetime with the specified time, retaining the date fields. * <p> * If the new time is invalid due to the time-zone, the time will be adjusted. * <p> * This instance is immutable and unaffected by this method call. * * @param time the local time * @return a copy of this datetime with a different time * @throws IllegalArgumentException if the time-of-day is invalid for the date * @throws NullPointerException if the time is null */ public DateTime withTime(LocalTime time) { return withTime( time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); }
/** * Returns a copy of this datetime with the specified time, retaining the date fields. * <p> * If the new time is invalid due to the time-zone, the time will be adjusted. * <p> * This instance is immutable and unaffected by this method call. * * @param time the local time * @return a copy of this datetime with a different time * @throws IllegalArgumentException if the time-of-day is invalid for the date * @throws NullPointerException if the time is null */ public DateTime withTime(LocalTime time) { return withTime( time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); }
getYear(), getMonthOfYear(), getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(), chrono);
getYear(), getMonthOfYear(), getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(), chrono);
int t = ((TimeExpression)valueArg).getTime(); LocalTime lT = LocalTime.fromMillisOfDay(t); this.value = KeyValueBuilder.initFrom(new OTime(lT.getHourOfDay(), lT.getMinuteOfHour(), lT.getSecondOfMinute(), lT.getMillisOfSecond())); this.path = path; return true;
@Override public String toNonNullValue(LocalTime value) { if (value.getMillisOfSecond() == 0) { if (value.getSecondOfMinute() == 0) { return Formatter.LOCAL_TIME_NOSECONDS_PRINTER.print(value); } return Formatter.LOCAL_TIME_NOMILLIS_PRINTER.print(value); } else { return value.toString(); } } }
@Override public String toNonNullValue(LocalTime value) { if (value.getMillisOfSecond() == 0) { if (value.getMinuteOfHour() == 0) { return Formatter.LOCAL_TIME_NOSECONDS_FORMATTER.print(value); } return Formatter.LOCAL_TIME_FORMATTER.print(value); } else { return value.toString(); } } }
@Override public Object map(Object obj) { val t = (LocalTime) obj; return Time.valueOf(java.time.LocalTime.of(t.getHourOfDay(), t.getMinuteOfHour(), t.getSecondOfMinute(), t.getMillisOfSecond())); } }
@Override public Time parse(String value) { if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) return null; // enclosing single quotes required, even for long literals if (!ParseUtils.isQuoted(value)) throw new InvalidTypeException("time values must be enclosed by single quotes"); value = value.substring(1, value.length() - 1); if (ParseUtils.isLongLiteral(value)) { long nanosOfDay; try { nanosOfDay = Long.parseLong(value); } catch (NumberFormatException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } return new Time(LocalTime.fromMillisOfDay(nanosOfDay / 1000000L).getMillisOfSecond()); } try { return new Time(LocalTime.parse(value).toDateTimeToday().getMillis()); } catch (RuntimeException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } }
private DateTime convertToDateTime(final DateTime currentDate, final LocalTime time) { return new DateTime(currentDate).withTime(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); }
Date datePart= ...; // The date parsed from the first user input String userTimeInput = ...; // The time of day from the user Locale userLocale = ...; DateTimeZone userTimeZone = ...; DateTime dateInUserTimeZone = new DateTime(datePart, userTimeZone); DateTimeFormatter formatter = DateTimeFormat.shortTime().withLocale(userLocale); LocalTime time = formatter.parseLocalTime(userTimeInput); Date newDate = dateInUserTimeZone.withTime(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()).toDate();
@Override public TimeOfDay fromNonNullValue(Time value) { DateTime dateTime = new DateTime(value.getTime()); LocalTime localTime = dateTime.toLocalTime(); final TimeOfDay timeOfDay = new TimeOfDay(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute(), localTime.getMillisOfSecond(), localTime.getChronology()); return timeOfDay; }
@Override public Timestamp toNonNullValue(LocalTime value) { DateTime zonedValue = new LocalDateTime( 1970,1,1,value.getHourOfDay(), value.getMinuteOfHour(), value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology() ).toDateTime(); final Timestamp timestamp = new Timestamp(zonedValue.getMillis()); return timestamp; } }
@Override public Time toNonNullValue(LocalTime value) { DateTime zonedValue = new LocalDateTime( 1970,1,1,value.getHourOfDay(), value.getMinuteOfHour(), value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology() ).toDateTime(); final Time time = new Time(zonedValue.getMillis()); return time; } }
@Override public TimeOfDay fromNonNullValue(Timestamp value) { final LocalTime localTime = Formatter.LOCAL_DATETIME_PARSER.parseDateTime(value.toString()).toLocalTime(); final TimeOfDay timeOfDay = new TimeOfDay(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute(), localTime.getMillisOfSecond(), localTime.getChronology()); return timeOfDay; }
@Override public TimeOfDay fromNonNullValue(Timestamp value) { DateTime dateTime = new DateTime(value.getTime()); LocalTime localTime = dateTime.toLocalTime(); final TimeOfDay timeOfDay = new TimeOfDay(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute(), localTime.getMillisOfSecond(), localTime.getChronology()); return timeOfDay; }
@Override public java.time.LocalTime convert(LocalTime in, Context context) throws Exception { if (in == null) return null; return java.time.LocalTime.of(in.getHourOfDay(), in.getMinuteOfHour(), in.getSecondOfMinute(), in.getMillisOfSecond() * 1000); } }
/** * Returns a copy of this datetime with the specified time, retaining the date fields. * <p> * If the new time is invalid due to the time-zone, the time will be adjusted. * <p> * This instance is immutable and unaffected by this method call. * * @param time the local time * @return a copy of this datetime with a different time * @throws IllegalArgumentException if the time-of-day is invalid for the date * @throws NullPointerException if the time is null */ public DateTime withTime(LocalTime time) { return withTime( time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); }
/** * Returns a copy of this datetime with the specified time, retaining the date fields. * <p> * If the new time is invalid due to the time-zone, the time will be adjusted. * <p> * This instance is immutable and unaffected by this method call. * * @param time the local time * @return a copy of this datetime with a different time * @throws IllegalArgumentException if the time-of-day is invalid for the date * @throws NullPointerException if the time is null */ public DateTime withTime(LocalTime time) { return withTime( time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); }
getYear(), getMonthOfYear(), getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(), chrono);