How can I convert YMD LDAP timestamps to date time in Java?

Viewed 537

For instance I have the date as: 20171208181856.0Z and I want to convert it into date time format using java. I don't seem to find any working solutions for it.

1 Answers

You can create DateTimeFormatter using input format and parse it into ZonedDateTime or OffsetDateTime

String dateTime = "20171208181856.0Z";

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss.SX");

OffsetDateTime offsetDateTime = OffsetDateTime.parse(dateTime,formatter);

System.out.println(offsetDateTime);
Related