Java date time format pattern for ISO_OFFSET_DATE_TIME

前端 未结 3 653
旧时难觅i
旧时难觅i 2021-01-27 16:25

I\'m after the date time format pattern for ISO_OFFSET_DATE_TIME

2019-09-30T10:05:16+10:00

yyyy-MM-dd\'T\'HH:mm:ssZ is

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-27 17:00

    You need uuuu-MM-dd'T'HH:mm:ssXXX here.

    String str = "2019-09-30T10:05:16+10:00";
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ssXXX");
    OffsetDateTime datetime = OffsetDateTime.parse(str, formatter);
    System.out.println(datetime);
    

提交回复
热议问题