Starting in Java 7, there’s the X
pattern string for ISO8601 time zone. For strings in the format you describe, use XXX
. See the documentation.
Sample:
System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
.format(new Date()));
Result:
2014-03-31T14:11:29+02:00