Here you can find the source of getDateFromFormattedDate(String dateStr, String format)
public static Date getDateFromFormattedDate(String dateStr, String format)
//package com.java2s; //License from project: Open Source License import java.util.*; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static Date getDateFromFormattedDate(String dateStr, String format) { try {/*from w w w.j av a2 s .c om*/ SimpleDateFormat sdf = new SimpleDateFormat(format); if (dateStr != null && !"XXXX".equals(dateStr)) { Date date = sdf.parse(dateStr); return date; } } catch (ParseException pe) { System.out.println("Exception: " + pe); } return new Date(0); } }