这是代码:
LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1451438792953L), ZoneId.of("UTC"));
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss.SSS'Z'");
String output = dateTimeFormatter.format(localDateTime);
这是localDateTime的值:
2015-12-30T01:26:32.953
这是输出的值:
2016-12-30T01:26:32.953Z
为什么要加一年?
在 java.time.temporal.WeekFields 中有几个带有 newYearWeek 的方法,这些方法有时将年份增加 1.为什么?
In java.time.temporal.WeekFields there are a couple of methods with a newYearWeek which increment the year by 1 on occasion. Why?
这是一个奇怪的错误.
来自 维基百科:
[YYYY] 表示 ISO 周编号年份,略不同于传统的公历年(见下文).
[YYYY] indicates the ISO week-numbering year which is slightly different from the traditional Gregorian calendar year (see below).
YYYY 是年份的 ISO-8601 样式表示.yyyy 是公历年份表示.YYYY is an ISO-8601 style representation of the year. yyyy is the Gregorian year-of-era representation. 由于两者的计算可以相差+1或-1,因此格式.更多有用信息请参见 YEAR_OF_ERA, YEAR 和 weekBasedYear.
Since the the calculation of the two can be different by +1 or -1, hence the formatting. More useful info at YEAR_OF_ERA, YEAR, and weekBasedYear.
这篇关于为什么Java的 java.time.format.DateTimeFormatter#format(LocalDateTime) 加一年?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
上传进度侦听器未触发(Google 驱动器 API)Upload progress listener not fired (Google drive API)(上传进度侦听器未触发(Google 驱动器 API))
使用 Google Drive SDK 将文件保存在特定文件夹中Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 将文件保存在特定文件夹中)
Google Drive Android API - 无效的 DriveId 和 Null ResourcGoogle Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 无效的 DriveId 和 Null ResourceId)
谷歌驱动api服务账户查看上传文件到谷歌驱动使Google drive api services account view uploaded files to google drive using java(谷歌驱动api服务账户查看上传文件到谷歌驱动使用java
Google Drive 服务帐号返回 403 usageLimitsGoogle Drive service account returns 403 usageLimits(Google Drive 服务帐号返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory;Google Drcom.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例