这段代码:
String dateString = "20210811T021500Z";
String dateFormat = "yyyyMMdd'T'HHmmss'Z'";
System.out.println(LocalDateTime.parse(dateString, dateFormat).toString());
System.out.println(LocalDateTime.parse(dateString, dateFormat).atZone(ZoneId.of("Europe/Budapest")).toString());
System.out.println(ZonedDateTime.of(LocalDateTime.parse(dateString, dateFormat), ZoneId.of("Europe/Budapest")).toString());
输出这个:
2021-08-11T02:15
2021-08-11T02:15+02:00[Europe/Budapest]
2021-08-11T02:15+02:00[Europe/Budapest]
如何打印调整后的时间?我希望结果是2021-08-11T04:15
.