本文整理了Java中java.time.ZonedDateTime.toLocalTime()
方法的一些代码示例,展示了ZonedDateTime.toLocalTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.toLocalTime()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:toLocalTime
[英]Gets the LocalTime part of this date-time.
This returns a LocalTime with the same hour, minute, second and nanosecond as this date-time.
[中]获取此日期时间的LocalTime部分。
这将返回与此日期时间相同的小时、分钟、秒和纳秒的本地时间。
代码示例来源:origin: spring-projects/spring-framework
@Override
public LocalTime convert(ZonedDateTime source) {
return source.toLocalTime();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public LocalTime convert(Calendar source) {
return calendarToZonedDateTime(source).toLocalTime();
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
public LocalTime convert(Calendar source) {
return calendarToZonedDateTime(source).toLocalTime();
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
public LocalTime convert(ZonedDateTime source) {
return source.toLocalTime();
}
}
代码示例来源:origin: neo4j/neo4j
@Override
LocalTime getLocalTimePart()
{
return value.toLocalTime();
}
代码示例来源:origin: neo4j/neo4j
@Override
OffsetTime getTimePart( Supplier<ZoneId> defaultZone )
{
ZoneOffset offset = value.getOffset();
LocalTime localTime = value.toLocalTime();
return OffsetTime.of( localTime, offset );
}
代码示例来源:origin: graphhopper/graphhopper
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;
}
代码示例来源:origin: blynkkk/blynk-server
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()));
}
代码示例来源:origin: oracle/helidon
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);
}
}
代码示例来源:origin: hibernate/hibernate-orm
@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 );
}
}
}
} );
} );
}
代码示例来源:origin: neo4j/neo4j
if ( cmp == 0 )
cmp = value.toLocalTime().getNano() - that.value.toLocalTime().getNano();
if ( cmp == 0 )
代码示例来源:origin: apache/wicket
@Override
protected LocalTime getLocalTime(ZonedDateTime temporal)
{
return temporal.toLocalTime();
}
}
代码示例来源:origin: org.simpleflatmapper/sfm-converter
@Override
public LocalTime convert(Date in, Context context) throws Exception {
if (in == null) return null;
return in.toInstant().atZone(dateTimeZone).toLocalTime();
}
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
public FutureRelativePartialDummyEntity(ZonedDateTime dateTime) {
localTime = dateTime.toLocalTime();
monthDay = MonthDay.from( dateTime );
offsetTime = OffsetTime.from( dateTime );
}
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
public FutureOrPresentRelativePartialDummyEntity(ZonedDateTime dateTime) {
localTime = dateTime.toLocalTime();
monthDay = MonthDay.from( dateTime );
offsetTime = OffsetTime.from( dateTime );
}
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
public FutureOrPresentRelativePartialDummyEntity(ZonedDateTime dateTime) {
localTime = dateTime.toLocalTime();
monthDay = MonthDay.from( dateTime );
offsetTime = OffsetTime.from( dateTime );
}
}
代码示例来源:origin: com.esotericsoftware/kryo
public void write (Kryo kryo, Output out, ZonedDateTime obj) {
LocalDateSerializer.write(out, obj.toLocalDate());
LocalTimeSerializer.write(out, obj.toLocalTime());
ZoneIdSerializer.write(out, obj.getZone());
}
代码示例来源:origin: pl.touk.esp/esp-process
public void write(Kryo kryo, Output out, ZonedDateTime obj) {
LocalDateSerializer.write(out, obj.toLocalDate());
LocalTimeSerializer.write(out, obj.toLocalTime());
ZoneIdSerializer.write(out, obj.getZone());
}
代码示例来源:origin: org.dbflute/dbflute-runtime
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;
}
代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-dynamic-forms-backend
@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);
}
内容来源于网络,如有侵权,请联系作者删除!