Here you can find the source of StringToDate(String str)
public static Date StringToDate(String str)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date StringToDate(String str, String pattern) { Date dateTime = null;// w ww. j a va 2 s . c o m try { if (str != null && !str.equals("")) { SimpleDateFormat formater = new SimpleDateFormat(pattern); dateTime = formater.parse(str); } } catch (Exception ex) { } return dateTime; } public static Date StringToDate(String str) { String _pattern = "yyyy-MM-dd"; return StringToDate(str, _pattern); } }