OffsetDateTime - print offset instead of Z
问题 I have this code: String date = "2019-04-22T00:00:00+02:00"; OffsetDateTime odt = OffsetDateTime .parse(date, DateTimeFormatter.ISO_OFFSET_DATE_TIME) .withOffsetSameInstant(ZoneOffset.of("+00:00")); System.out.println(odt); This print: 2019-04-21T22:00Z How can I print 2019-04-21T22:00+00:00 ? With offset instead of Z . 回答1: None of the static DateTimeFormatter s do this in the standard library. They either default to Z or GMT . To achieve +00:00 for no offset, you will have to build your own