DateTimeFormatter formatter0 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.of("Asia/Shanghai"));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssz");
ZonedDateTime zoneTime = ZonedDateTime.parse("2018-08-07 08:00:01", formatter0);
System.out.println(zoneTime.withFixedOffsetZone().format(formatter));
输出结果:2018-08-07T08:00:01+08:00
此处有ZonedDateTime类的详细API: