Here you can find the source of getDateFromString(final String inputStringDate, final String format)
public static Date getDateFromString(final String inputStringDate, final String format)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getDateFromString(final String inputStringDate, final String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); Calendar calendar = Calendar.getInstance(); try {//from www . j a va2s. c o m calendar.setTime(dateFormat.parse(inputStringDate)); } catch (ParseException e) { System.err.println("Error parsing date " + e.getMessage()); return null; } return calendar.getTime(); } }