Here you can find the source of iso8601ToDate(String s)
private static synchronized Date iso8601ToDate(String s) throws ParseException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final SimpleDateFormat ISO8601_DATE_FORMAT_MILLIS = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); private static final SimpleDateFormat ISO8601_DATE_FORMAT_SECS = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'"); private static final SimpleDateFormat ISO8601_DATE_FORMAT_MINS = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); private static final SimpleDateFormat ISO8601_DATE_FORMAT_DATE = new SimpleDateFormat("yyyy-MM-dd"); private static synchronized Date iso8601ToDate(String s) throws ParseException { Date d = null;/*from w ww . j a va 2 s.co m*/ try { d = ISO8601_DATE_FORMAT_MILLIS.parse(s); } catch (ParseException e1) { try { d = ISO8601_DATE_FORMAT_SECS.parse(s); } catch (ParseException e2) { try { d = ISO8601_DATE_FORMAT_MINS.parse(s); } catch (ParseException e3) { d = ISO8601_DATE_FORMAT_DATE.parse(s); } } } return d; } }