在
Java 8中,我想将datetime从UTC转换为ACST(UTC 9:30).
输入 – > 2014-09-14T17:00:00 00:00
输出 – > 2014-09-15 02:30:00
String isoDateTime = "2014-09-14T17:00:00+00:00";
LocalDateTime fromIsoDate = LocalDateTime.parse(isoDateTime,DateTimeFormatter.ISO_OFFSET_DATE_TIME);
ZoneOffset offset = ZoneOffset.of("+09:30");
OffsetDateTime acst = OffsetDateTime.of(fromIsoDate,offset);
System.out.println(acst.toString()); // 2014-09-14T17:00+09:30
System.out.println(acst.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); // 2014-09-14T17:00:00+09:30
为什么不执行偏移?