Here you can find the source of parseDate(String s)
public static Date parseDate(String s) throws Exception
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date parseDate(String s) throws Exception { DateFormat dateLong = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss"); DateFormat dateOnly = new SimpleDateFormat("yyyy/MM/dd"); DateFormat dateTime = new SimpleDateFormat("HH:mm:ss"); try {// w w w .j av a2s.c om return dateLong.parse(s); } catch (Exception e) { try { return dateOnly.parse(s); } catch (Exception t) { return dateTime.parse(s); } } } }