Parsing custom formatted date string into Date object using SimpleDateFormat

This example shows how to parse string containing date and time in custom formats into Date object using Java SimpleDateFormat class.

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class ParsingCustomFormatDate {

public static void main(String[] args) {

//create object of SimpleDateFormat class with custom format
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");

//parse string containing specified format into date object
Date date = sdf.parse("11/10/14");
catch(ParseException pe)
System.out.println("Parse Exception : " + pe);