I know this is a very silly question but I’m unable to find a suitable dateformatter for the given Date: 2020/04/01T20:00-05:00
or 2020/03/05T21:45-07:00
. Any sort of help would be highly appreciated.
Advertisement
Answer
You can’t find one because that is a non-standard format. -
is industry standard, using timezone offsets is outdated. Thus, you’d have to make it yourself. But this is quite simple, fortunately!
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("uuuu/MM/dd'T'HH:mmZZZZZ"); var zdt = ZonedDateTime.parse("2020/04/01T20:00-05:00", dtf); System.out.println(zdt); > 2020-04-01T20:00-05:00