Here you can find the source of fromString(String dateStr, String dateFormat)
public static Date fromString(String dateStr, String dateFormat) throws java.text.ParseException
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final String DATE_FORMAT = "yyyy-MM-dd G HH:mm:ss z"; public static Date fromString(String dateStr) throws java.text.ParseException { return fromString(dateStr, DATE_FORMAT); }/* w w w .j a va 2s .co m*/ public static Date fromString(String dateStr, String dateFormat) throws java.text.ParseException { return fromString(dateStr, dateFormat, Locale.ENGLISH); } public static Date fromString(String dateStr, String dateFormat, Locale locale) throws java.text.ParseException { SimpleDateFormat format = new SimpleDateFormat(dateFormat, locale); return format.parse(dateStr); } }