Here you can find the source of stringToDate(String dateString)
public static Date stringToDate(String dateString)
//package com.java2s; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date stringToDate(String dateString) { String sf = "yyyy-MM-dd HH:mm:ss"; Date dt = stringToDate(dateString, sf); return dt; }/*from w w w.j a v a2 s . co m*/ public static Date stringToDate(String dateString, String sf) { ParsePosition pos = new ParsePosition(0); SimpleDateFormat sdf = new SimpleDateFormat(sf); Date dt = sdf.parse(dateString, pos); return dt; } }