Here you can find the source of parseIso8601(String iso8601String)
public static long parseIso8601(String iso8601String) throws ParseException
//package com.java2s; /**//from w w w . j a v a 2 s . c o m * Copyright (c) 2012 Todoroo Inc * * See the file "LICENSE" for the full license governing this code. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long parseIso8601(String iso8601String) throws ParseException { if (iso8601String == null) return 0; String formatString; if (isoStringHasTime(iso8601String)) { // Time exists iso8601String = iso8601String.replace("Z", "+00:00"); //$NON-NLS-1$ //$NON-NLS-2$ try { iso8601String = iso8601String.substring(0, 22) + iso8601String.substring(23); } catch (IndexOutOfBoundsException e) { e.printStackTrace(); throw new ParseException("Invalid ISO 8601 length for string " + iso8601String, 0); //$NON-NLS-1$ } formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; //$NON-NLS-1$ } else { formatString = "yyyy-MM-dd"; //$NON-NLS-1$ } Date result = new SimpleDateFormat(formatString).parse(iso8601String); return result.getTime(); } public static boolean isoStringHasTime(String iso8601String) { return iso8601String.length() > 10; } }