Here you can find the source of getStringToDate(String str)
public static Date getStringToDate(String str)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getStringToDate(String str) { SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date parse = null;/* www . j a v a2 s . c o m*/ str = str.replace("T", " "); try { parse = date.parse(str); } catch (ParseException e) { e.printStackTrace(); } return parse; } public static Date parse(String source, String format) throws ParseException { if (source == null) { return null; } DateFormat df = null; if (format != null) { df = new SimpleDateFormat(format); } else { df = DateFormat.getDateInstance(DateFormat.DEFAULT); } return df.parse(source); } }