Here you can find the source of parserDate(String str)
public static Date parserDate(String str)
//package com.java2s; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static final String format0 = "yyyy-MM-dd HH:mm:ss"; public static Date parserDate(String str, String format) { if (null == str || "".equals(str) || "NULL".equalsIgnoreCase(str)) return null; if (null == format) format = format0;//from w w w.j av a 2 s .c om java.util.Date d = Calendar.getInstance().getTime(); if (str.length() == 10) str = str + " 00:00:00"; SimpleDateFormat formatter = new SimpleDateFormat(format); ParsePosition pos = new ParsePosition(0); d = formatter.parse(str, pos); return d; } public static Date parserDate(String str) { if (null == str) return null; return parserDate(str, format0); } }