Here you can find the source of parseVariuosDateTime(String dateStr)
public static Date parseVariuosDateTime(String dateStr)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; public class Main { public static Date parseVariuosDateTime(String dateStr) { // Preparation int i = dateStr.indexOf('('); if (i >= 0) { dateStr = dateStr.substring(0, i); }//from w w w . j a v a 2 s . c o m SimpleDateFormat dateFormat; List<String> patterns = new ArrayList<String>(); patterns.add("MM/dd HH:mm:ss"); patterns.add("MM/dd HH:mm"); patterns.add("MM/dd/yyyy HH:mm:ss"); patterns.add("MM/dd/yyyy HH:mm"); patterns.add("dd-MM-yyyy HH:mm"); patterns.add("dd-MM-yyyy HH:mm:ss"); Date res = null; for (String pattern : patterns) { dateFormat = new SimpleDateFormat(pattern); try { res = dateFormat.parse(dateStr); } catch (ParseException e) { } } return res; } }