Here you can find the source of parseDate(String str)
public static Date parseDate(String str) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String[] parsePatterns = new String[] { "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "HH:mm", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd", "yyyyMMdd" }; public static Date parseDate(String str) throws ParseException { return parseDate(str, parsePatterns[1]); }// w w w . j a v a2 s . c o m public static Date parseDate(String str, String parsePattern) throws ParseException { SimpleDateFormat format = new SimpleDateFormat(parsePattern); Date date = null; try { date = format.parse(str); } catch (ParseException e) { e.printStackTrace(); } return date; } }