Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final DateFormat dateFormat = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT); public static Date getFormattedDate(String dateString) { try { return dateFormat.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } throw new IllegalArgumentException("Invalid date string " + dateString); } }