Here you can find the source of stringToDate(String strDate)
public static Date stringToDate(String strDate) throws ParseException
//package com.java2s; //License from project: LGPL import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; public static Date stringToDate(String strDate) throws ParseException { DateFormat df = new SimpleDateFormat(DATE_FORMAT); Date result = null;//from w w w . ja v a2 s .c o m if (!isBlank(strDate)) { result = df.parse(strDate); } return result; } public static boolean isBlank(CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if ((Character.isWhitespace(cs.charAt(i)) == false)) { return false; } } return true; } }