It appears that SimpleDateFormat
doesn't support ISO8601 time zone formats. If you know for certain that your time zone will always end in the format of -##:##
(or +##:##
) then you could just remove the last :
so that your existing formatter works. E.g. this parses your date:
String input = "2011-04-17T22:02:00.001-07:00";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date date = sdf.parse(input.replaceAll(":(..)$", "$1"));
Be careful however, apparently ISO8601 allows for some variations whereby this wouldn't work.