Here you can find the source of parseDate(String datestr)
public static Date parseDate(String datestr)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static Date parseDate(String datestr) { if (null == datestr || "".equals(datestr)) { return null; }/* w w w . j a v a 2s . c o m*/ try { String fmtstr = null; if (datestr.indexOf(':') > 0) { fmtstr = "yyyy-MM-dd HH:mm:ss"; } else { fmtstr = "yyyy-MM-dd"; } SimpleDateFormat sdf = new SimpleDateFormat(fmtstr, Locale.UK); return sdf.parse(datestr); } catch (Exception e) { return null; } } }