Here you can find the source of strToDate(String date)
public static Date strToDate(String date)
//package com.java2s; /**/*w w w . jav a 2s .c o m*/ * Core-level framework class: String and Date basic utility methods. * <br><br> * Encapsulates utility methods for everyday programming tasks * with Strings, Dates and other common stuff. * <br> * Creation date: 18/09/2003<br> * Last Update: 18/09/2003<br> * (c) 2003 Martin Cordova<br> * This code is released under the LGPL license<br> * @author Martin Cordova (some code written by Carlos Pineda) */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; public class Main { public static Date strToDate(String date) { if (date == null) { return null; } Date realDate = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date newDate = sdf.parse(date); String str = sdf.format(newDate); realDate = sdf.parse(str); } catch (ParseException e) { e.printStackTrace(); } return realDate; } public static String format(String pattern, Map<String, Object> arguments) { String formatedStr = pattern; for (String key : arguments.keySet()) { formatedStr = formatedStr.replaceAll("\\{:" + key + "\\}", arguments.get(key).toString()); } return formatedStr; } }