Here you can find the source of toDate(String sdate, SimpleDateFormat dateFormater)
public static Date toDate(String sdate, SimpleDateFormat dateFormater)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private final static ThreadLocal<SimpleDateFormat> DATE_FORMATER = new ThreadLocal<SimpleDateFormat>() { @Override//from ww w.j a v a2 s . c om protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } }; public static Date toDate(String sdate) { return toDate(sdate, DATE_FORMATER.get()); } public static Date toDate(String sdate, SimpleDateFormat dateFormater) { try { return dateFormater.parse(sdate); } catch (ParseException e) { return null; } } }