Here you can find the source of strToDate(String strDate, String format)
public static Date strToDate(String strDate, String format)
//package com.java2s; //License from project: Open Source License import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date strToDate(String strDate) { return strToDate(strDate, "yyyy-MM-dd"); }/* w ww.java 2 s . co m*/ public static Date strToDate(String strDate, String format) { if (strDate == null) { return null; } SimpleDateFormat formatter = new SimpleDateFormat(format); ParsePosition pos = new ParsePosition(0); Date strtodate = formatter.parse(strDate, pos); return strtodate; } }