Here you can find the source of toDate(String formatDate, String stringDate)
public static Date toDate(String formatDate, String stringDate) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date toDate(String formatDate, String stringDate) throws ParseException { if (stringDate == null || stringDate.isEmpty()) { return null; }//from w ww .j a v a 2s . c o m SimpleDateFormat format = new SimpleDateFormat(formatDate); return format.parse(stringDate); } }