@Override public LocalTime convert(ZonedDateTime source) { return source.toLocalTime(); } }
@Override public LocalTime convert(Calendar source) { return calendarToZonedDateTime(source).toLocalTime(); } }
@Override public LocalTime convert(Calendar source) { return calendarToZonedDateTime(source).toLocalTime(); } }
@Override public LocalTime convert(ZonedDateTime source) { return source.toLocalTime(); } }
@Override LocalTime getLocalTimePart() { return value.toLocalTime(); }
@Override OffsetTime getTimePart( Supplier<ZoneId> defaultZone ) { ZoneOffset offset = value.getOffset(); LocalTime localTime = value.toLocalTime(); return OffsetTime.of( localTime, offset ); }
private long millisOnTravelDay(EdgeIteratorState edge, long instant) { final ZoneId zoneId = gtfsStorage.getTimeZones().get(flagEncoder.getValidityId(edge.getFlags())).zoneId; return Instant.ofEpochMilli(instant).atZone(zoneId).toLocalTime().toNanoOfDay() / 1000000L; }
public void addReportSpecificAtTime(StringBuilder sb, ZoneId zoneId) { ZonedDateTime zonedAt = getZonedFromTs(atTime, zoneId); LocalTime localTime = zonedAt.toLocalTime(); sb.append(", ").append("at ").append(LocalTime.of(localTime.getHour(), localTime.getMinute())); }
void validate(TimeValidator validator, ZonedDateTime now, Errors.Collector collector) { // between times - it must fit at least one boolean valid = false; LocalTime nowTime = now.toLocalTime(); for (BetweenTime betweenTime : betweenTimes) { if (betweenTime.isValid(nowTime)) { valid = true; } } if (!valid) { collector.fatal(validator, nowTime.format(TIME_FORMATTER) + " is in neither of allowed times: " + betweenTimes); } DayOfWeek dayOfWeek = now.getDayOfWeek(); if (!daysOfWeek.contains(dayOfWeek)) { collector.fatal(validator, dayOfWeek + " is not in allowed days: " + daysOfWeek); } }
@Test public void testDBTimeValueAsEpochDST() { doInHibernate( this::sessionFactory, session -> { session.doWork( connection -> { Time time = Time.valueOf( LocalTime.of( 12, 0, 0 ) ); GregorianCalendar utcCalendar = new GregorianCalendar( TimeZone.getTimeZone( "UTC" ) ); utcCalendar.setTimeInMillis( time.getTime() ); LocalTime utcLocalTime = utcCalendar.toZonedDateTime().toLocalTime(); Time utcTime = Time.valueOf( utcLocalTime ); try (PreparedStatement ps = connection.prepareStatement( "INSERT INTO Person (id, shiftStartTime) VALUES (?, ?)" )) { ps.setLong( 1, 1L ); ps.setTime( 2, time, new GregorianCalendar( TimeZone.getTimeZone( "UTC" ) ) ); ps.executeUpdate(); } try (Statement st = connection.createStatement()) { try (ResultSet rs = st.executeQuery( "SELECT shiftStartTime FROM Person WHERE id = 1" )) { while ( rs.next() ) { Time dbTime = rs.getTime( 1 ); assertEquals( utcTime, dbTime ); } } } } ); } ); }
if ( cmp == 0 ) cmp = value.toLocalTime().getNano() - that.value.toLocalTime().getNano(); if ( cmp == 0 )
@Override protected LocalTime getLocalTime(ZonedDateTime temporal) { return temporal.toLocalTime(); } }
@Override public LocalTime convert(Date in, Context context) throws Exception { if (in == null) return null; return in.toInstant().atZone(dateTimeZone).toLocalTime(); } }
public FutureRelativePartialDummyEntity(ZonedDateTime dateTime) { localTime = dateTime.toLocalTime(); monthDay = MonthDay.from( dateTime ); offsetTime = OffsetTime.from( dateTime ); } }
public FutureOrPresentRelativePartialDummyEntity(ZonedDateTime dateTime) { localTime = dateTime.toLocalTime(); monthDay = MonthDay.from( dateTime ); offsetTime = OffsetTime.from( dateTime ); } }
public FutureOrPresentRelativePartialDummyEntity(ZonedDateTime dateTime) { localTime = dateTime.toLocalTime(); monthDay = MonthDay.from( dateTime ); offsetTime = OffsetTime.from( dateTime ); } }
public void write (Kryo kryo, Output out, ZonedDateTime obj) { LocalDateSerializer.write(out, obj.toLocalDate()); LocalTimeSerializer.write(out, obj.toLocalTime()); ZoneIdSerializer.write(out, obj.getZone()); }
public void write(Kryo kryo, Output out, ZonedDateTime obj) { LocalDateSerializer.write(out, obj.toLocalDate()); LocalTimeSerializer.write(out, obj.toLocalTime()); ZoneIdSerializer.write(out, obj.getZone()); }
protected static LocalTime doConvertToLocalTime(Object obj, TimeZone timeZone, String pattern, Locale locale) { if (obj instanceof String) { return doParseStringAsLocalTime((String) obj, pattern, locale); } else if (obj instanceof LocalDateTime) { return ((LocalDateTime) obj).toLocalTime(); } else if (obj instanceof LocalTime) { return (LocalTime) obj; } final TimeZone realZone = chooseRealZone(timeZone); final Date zonedResourceDate = toZonedResourceDate(obj, realZone); return zonedResourceDate != null ? toZonedDateTime(zonedResourceDate, realZone).toLocalTime() : null; }
@Test public void testToLocalTimeValue() { when(field.getStandaloneClassName()).thenReturn(LocalTime.class.getName()); LocalTime originalValue = LocalTime.now(); marshaller.init(originalValue, field, formDefinition, context); Date flatValue = marshaller.toFlatValue(); assertNotNull(flatValue); assertEquals(originalValue, flatValue.toInstant().atZone(ZoneId.systemDefault()).toLocalTime()); Object rawValue = marshaller.toRawValue(flatValue); assertNotNull(rawValue); assertEquals(originalValue, rawValue); }