Java SimpleDateFormat Timezone offset with minute separated by colon

user2139437 picture user2139437 · Mar 6, 2013 · Viewed 35k times · Source

How can I get my date formatted as 2012-11-25T23:50:56.193+01:00 using SimpleDateFormat?
If I use Z in the format like

yyyy-MM-dd'T'hh:mm:ss.SSSZ

then it shows

2013-03-06T11:49:05.490+0100

Answer

ejain picture ejain · Apr 30, 2013

You can get the timezone offset formatted like +01:00 with the SimpleDateFormat in Java 7 (yyyy-MM-dd'T'HH:mm:ss.SSSXXX), or with the Joda's DateTimeFormat (yyyy-MM-dd'T'HH:mm:ss.SSSZZ).