public static Date parse(String date){
  try {
    int offset=0;
    int year=parseInt(date,offset,offset+=4);
    checkOffset(date,offset,'-');
    int month=parseInt(date,offset+=1,offset+=2);
    checkOffset(date,offset,'-');
    int day=parseInt(date,offset+=1,offset+=2);
    checkOffset(date,offset,'T');
    int hour=parseInt(date,offset+=1,offset+=2);
    checkOffset(date,offset,':');
    int minutes=parseInt(date,offset+=1,offset+=2);
    checkOffset(date,offset,':');
    int seconds=parseInt(date,offset+=1,offset+=2);
    Calendar calendar=new GregorianCalendar(TIMEZONE_GMT);
    calendar.setLenient(false);
    calendar.set(Calendar.YEAR,year);
    calendar.set(Calendar.MONTH,month - 1);
    calendar.set(Calendar.DAY_OF_MONTH,day);
    calendar.set(Calendar.HOUR_OF_DAY,hour);
    calendar.set(Calendar.MINUTE,minutes);
    calendar.set(Calendar.SECOND,seconds);
    return calendar.getTime();
  }
 catch (  IndexOutOfBoundsException e) {
    throw new IllegalArgumentException("Failed to parse date " + date,e);
  }
catch (  NumberFormatException e) {
    throw new IllegalArgumentException("Failed to parse date " + date,e);
  }
catch (  IllegalArgumentException e) {
    throw new IllegalArgumentException("Failed to parse date " + date,e);
  }
}

public static Date parse ( String date ) { try { int offset = 0 ; int year = parseInt ( date , offset , offset += 4 ) ; checkOffset ( date , offset , '-' ) ; int month = parseInt ( date , offset += 1 , offset += 2 ) ; checkOffset ( date , offset , '-' ) ; int day = parseInt ( date , offset += 1 , offset += 2 ) ; checkOffset ( date , offset , 'T' ) ; int hour = parseInt ( date , offset += 1 , offset += 2 ) ; checkOffset ( date , offset , ':' ) ; int minutes = parseInt ( date , offset += 1 , offset += 2 ) ; checkOffset ( date , offset , ':' ) ; int seconds = parseInt ( date , offset += 1 , offset += 2 ) ; Calendar calendar = new GregorianCalendar ( TIMEZONE_GMT ) ; calendar . setLenient ( false ) ; calendar . set ( Calendar . YEAR , year ) ; calendar . set ( Calendar . MONTH , month - 1 ) ; calendar . set ( Calendar . DAY_OF_MONTH , day ) ; calendar . set ( Calendar . HOUR_OF_DAY , hour ) ; calendar . set ( Calendar . MINUTE , minutes ) ; calendar . set ( Calendar . SECOND , seconds ) ; return calendar . getTime ( ) ; } catch ( IndexOutOfBoundsException e ) { throw new IllegalArgumentException ( "Failed to parse date " + date , e ) ; } catch ( NumberFormatException e ) { throw new IllegalArgumentException ( "Failed to parse date " + date , e ) ; } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException ( "Failed to parse date " + date , e ) ; } }
parse a date from iso - 8601 formatted string . it expects a format yyyy - mm - ddthh : mm : ss
