Here you can find the source of stringToDateTime(String stringDate, String format)
public static final Date stringToDateTime(String stringDate, String format)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final Date stringToDateTime(String stringDate, String format) {//from w w w.j a va 2 s . c o m if (stringDate == null) { return null; } try { return getFormat(format).parse(stringDate); } catch (ParseException e) { throw new RuntimeException(e); } } public static final DateFormat getFormat(String format) { return new SimpleDateFormat(format); } }