Here you can find the source of parse(String dateString)
public static Date parse(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 v a 2 s . c o 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 parse(String dateString) throws ParseException { try { return COMMON_FORMAT.get().parse(dateString); } catch (ParseException e) { return DATE_FORMAT.get().parse(dateString); } } }