Format a date

String format(Date date)
Formats a Date into a date/time string.
StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
Overrides Format.

import java.text.DateFormat;
import java.util.Date;

public class Main{
  public static void main(String args[]) {
    DateFormat df = DateFormat.getDateInstance();
    System.out.println(df.format(new Date()));
   }
}

The output:


18-Nov-2010
Home 
  Java Book 
    Essential Classes  

DataFormat:
  1. DataFormat class
  2. Create new DateFormat instance
  3. Constants from DateFormat
  4. Format a date
  5. Get all locales
  6. Parse string to get Date