Here you can find the source of convertToDate(String strDate, String format)
public static Date convertToDate(String strDate, String format) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date convertToDate(String strDate, String format) throws ParseException { SimpleDateFormat sf = new SimpleDateFormat(format); return sf.parse(strDate); }//w w w . jav a 2 s . com }