Convert datetime with "yyyy-MM-dd'T'HH:mm:ss.SSSZ" format

I’m trying to convert a datetime that I get to local time. Maybe I’m doing something wrong but java does not like the format.

Here is an example date ‘2018-04-25T14:05:15.953Z’
From the Java simpleDateFormat this appears to be the format “yyyy-MM-dd’T’HH:mm:ss.SSSZ”

Thank you,

You need to escape the Z in your incoming date - that’s a valid formatting character in SimpleDateFormat.

stringDate = '2018-04-25T14:05:15.953Z'
format = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

print system.date.parse(stringDate, format)
1 Like