Convert date into AEST using java

空扰寡人 提交于 2019-11-28 02:29:36

You have to use the formatter when parsing the date string. Also you need to tell it to change the zone or zone offset to get it into AEST/AEDT.

This might work:

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXX"); 
ZonedDateTime zdt = OffsetDateTime.parse(input, dtf)
    .atZoneSameInstant(ZoneId.of("Australia/Sydney"));
String dateInTimeZone = zdt.format(dtf);

The offset will appear as "+1000" or "+1100" depending on the time of year.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!