Here you can find the source of parseString2Date(String sDate, String format)
public static Date parseString2Date(String sDate, String format) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static Date parseString2Date(String sDate, String format) throws ParseException { if (format == null || "".equals(format)) { format = "yyyy-MM-dd HH:mm:ss"; }//w w w .j a v a2 s. co m SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.parse(sDate); } }