What does ‘SSSXXX’ mean in a java simple date format object?

I’ve found this in some legacy code that I don’t understand. Does anyone know what the SSSXXX bit means, it seems to be adding 2 hours to my date!?

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");

Answer:

According to the API S refers to milliseconds and X to the timezone.

The “Examples” section contains an example of SSSXXX yielding a three-digit millisecond representation followed by a “full” timezone offset “-07:00”. XX would have resulted in the medium format “-0700” and X simply “-07”

Leave a Comment