java-ZonedDateTime将正常时间戳转换为yyyy-MM-dd'T'HH:mm:ssz格式的时间戳


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:

http://www.cnblogs.com/lshan/p/9221296.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM