Here you can find the source of toDate(String dateValue, String format)
public static final Date toDate(String dateValue, String format)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final Date toDate(String dateValue, String format) { Date value = null;/*from w ww. ja v a 2 s . co m*/ try { value = newDateFormat(format).parse(dateValue); } catch (Exception e) { // ignore } return value; } public static final DateFormat newDateFormat(String format) { return new SimpleDateFormat(format, Locale.getDefault()); } public static final DateFormat newDateFormat(String format, Locale locale) { return new SimpleDateFormat(format, locale); } }