Here you can find the source of convertStringToDate(String dt)
public static Date convertStringToDate(String dt)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date convertStringToDate(String dt) { if (dt == null || dt.equals("")) { return null; }/*from w ww .j a v a 2 s . c o m*/ return convertStringToDate("yyyy-MM-dd", dt); } public static Date convertStringToDate(String style, String dt) { if (dt == null || dt.equals("")) { return null; } if (style == null || style.equals("")) { style = "yyyy-MM-dd"; } SimpleDateFormat dateFormat = new SimpleDateFormat(style); dateFormat.setLenient(false); try { return dateFormat.parse(dt); } catch (ParseException ex) { return null; } } }