Here you can find the source of stringToDatetime(String string)
public static Date stringToDatetime(String string) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date stringToDatetime(String string) throws ParseException { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date dateTime = dateFormat.parse(string); return dateTime; }/*from w w w. j a va 2 s . co m*/ }