Data Type Java Tutorial

Leniency refers to whether or not a strict rule will be applied at parsing.
If a DateFormat object is lenient, it will accept Jan 32, 2005.
In fact, it will take the liberty of converting it to Feb 1, 2006.
By default, a DateFormat object is lenient.

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
public class MainClass {
  public static void main(String[] args) {
    DateFormat shortDf = DateFormat.getDateInstance(DateFormat.SHORT);
    DateFormat mediumDf = DateFormat.getDateInstance(DateFormat.MEDIUM);
    DateFormat longDf = DateFormat.getDateInstance(DateFormat.LONG);
    DateFormat fullDf = DateFormat.getDateInstance(DateFormat.FULL);
    System.out.println(shortDf.format(new Date()));
    System.out.println(mediumDf.format(new Date()));
    System.out.println(longDf.format(new Date()));
    System.out.println(fullDf.format(new Date()));
    // parsing
    try {
      Date date = shortDf.parse("Jan 32, 2005");
    } catch (ParseException e) {
    }
  }
}
1/26/07
Jan 26, 2007
January 26, 2007
Friday, January 26, 2007