如何javax.time.Instant
在本地时区将 a 格式化为字符串?以下将 local 转换Instant
为UTC,而不是我期望的本地时区。删除对的调用toLocalDateTime()
也是如此。我怎样才能得到当地时间?
public String getDateTimeString( final Instant instant )
{
checkNotNull( instant );
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
DateTimeFormatter formatter = builder.appendPattern( "yyyyMMddHHmmss" ).toFormatter();
return formatter.print( ZonedDateTime.ofInstant( instant, TimeZone.UTC ).toLocalDateTime() );
}