Here you can find the source of parseISO8601DateString(String dateString)
public static Date parseISO8601DateString(String dateString) throws ParseException
//package com.java2s; // Licensed to the Apache Software Foundation (ASF) under one import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date parseISO8601DateString(String dateString) throws ParseException { // -> SimpleDateFormat uses GMT[-+]hh:mm for the TZ so first we need to // convert the string with this value SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"); //this is zero time so we need to add that TZ indicator for if (dateString.endsWith("Z")) { dateString = dateString.substring(0, dateString.length() - 1) + "GMT-00:00"; } else { // -> -0700 is valid but we need to change it to -07:00 for SimpleDateFormat dateString = dateString.replaceFirst("-(\\d\\d)(\\d\\d)", "-$1:$2"); int inset = 6; String s0 = dateString .substring(0, dateString.length() - inset); String s1 = dateString.substring(dateString.length() - inset, dateString.length()); dateString = s0 + "GMT" + s1; }/*from w w w . j a v a2 s .co m*/ //System.out.println( "parseDate: [" + dateString + "]" ); return df.parse(dateString); } }