Here you can find the source of parseDate(String dateString)
public static Date parseDate(String dateString) throws ParseException
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final ThreadLocal<DateFormat> COMMON_FORMAT = new ThreadLocal<DateFormat>() { @Override// w w w . ja va 2 s.co m protected DateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } }; private static final ThreadLocal<DateFormat> DATE_FORMAT = new ThreadLocal<DateFormat>() { @Override protected DateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd"); } }; public static Date parseDate(String dateString) throws ParseException { return DATE_FORMAT.get().parse(dateString); } public static Date parse(String dateString) throws ParseException { try { return COMMON_FORMAT.get().parse(dateString); } catch (ParseException e) { return DATE_FORMAT.get().parse(dateString); } } }