how to parse this date format in java? 2022-01-19T18:14:17 03:00 I tried SimpleDateFormat("yyyy-MM-dd HH:mm:ssz"), but it didn't work.
CodePudding user response:
Use a ZonedDateTime.
ZonedDateTime t = ZonedDateTime.parse("2022-01-19T18:14:17 03:00");
This uses the default zone you are in (only the offset 03:00 is given. toString is the inverse operation.
The format of the input is the ISO standard with T for time.
This means you do not need a DateTimeFormatter.
If you need to use the obsolete old Date:
Date date = Date.fromInstant(t.toInstant());
CodePudding user response:
Maybe it doesn't read 'T' "2022-01-19T18:14:17 03:00", or try to fit the data to Examples formats
