Here you can find the source of convertStringToDate(String dateString, String pattern)
public static Date convertStringToDate(String dateString, String pattern) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; public static Date convertStringToDate(String dateString, String pattern) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.parse(dateString); }//from www .ja v a2 s .c o m public static Date convertStringToDate(String dateString) { try { SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_FORMAT); return sdf.parse(dateString); } catch (ParseException e) { return null; } } }