更新时间:2023-01-17 08:00:11
方法 ofLocalizedDate()
, ofLocalizedTime()
和 ofLocalizedDateTime()
提供本地化格式。
The methods ofLocalizedDate()
, ofLocalizedTime()
and ofLocalizedDateTime()
provide the localized formats.
格式化 Instant
需要时区。这可以使用 withZone()
添加到格式化程序中:
To format an Instant
a time-zone is required. This can be added to the formatter using withZone()
:
DateTimeFormatter formatter =
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
.withLocale(UK)
.withZone(ZoneId.systemDefault());
如果没有区域,JSR-310格式化器不知道如何将瞬间转换为人类日期 - 时间字段。
Without the zone, JSR-310 formatter has no knowledge of how to convert the instant to human date-time fields.