Recently, I faced a date conversion task: convert a string date “yyyy-MM-ddZ” (i.e. “1983-09-15+03:00”) to the ISO8601 standard “yyyy-MM-dd’T’HH:mm:ss.SSSZ” (i.e. “1983-09-15T03:00:00.000+03:00”).

I used Apache Joda time to convert date. First, add a Maven dependency in pom.xml

<!-- -->

To format a string containing date, I used this code:

DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-ddZ");
DateTime dt = format.parseDateTime("1983-09-15+03:00")
.withTime(3, 0, 0, 0);


The result in a console will be 1983-09-15T03:00:00.000+03:00