Here you can find the source of StringToDate(String str, String format)
public static Date StringToDate(String str, String format) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date StringToDate(String str) throws ParseException { return StringToDate(str, null); }/*from w ww . j a v a 2 s .c o m*/ public static Date StringToDate(String str, String format) throws ParseException { if (str == null) { return null; } if (format == null) { format = "yyyy-MM-dd"; } DateFormat df = new SimpleDateFormat(format); return df.parse(str); } }