Here you can find the source of parseDateStringToDate(DateFormat format, String dateString)
public static Date parseDateStringToDate(DateFormat format, String dateString)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.util.Date; import java.util.TimeZone; public class Main { public static Date parseDateStringToDate(DateFormat format, String dateString) { if (format != null) { synchronized (format) { try { return format.parse(dateString); } catch (ParseException e) { return null; }/*from www . j a va 2 s . c o m*/ } } else { // String message = "format is null,the dataString is " + // dateString; return null; } } public static Date parseDateStringToDate(DateFormat format, String time, TimeZone timeZone) { synchronized (format) { try { format.setTimeZone(timeZone); return format.parse(time); } catch (ParseException e) { return null; } } } }