The DateFormat Class : Date « Utility Classes « SCJP






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

public class MainClass {
  public static void main(String[] args) {
    Date d1 = new Date(1000000000000L);

    DateFormat[] dfa = new DateFormat[6];
    dfa[0] = DateFormat.getInstance();
    dfa[1] = DateFormat.getDateInstance();
    dfa[2] = DateFormat.getDateInstance(DateFormat.SHORT);
    dfa[3] = DateFormat.getDateInstance(DateFormat.MEDIUM);
    dfa[4] = DateFormat.getDateInstance(DateFormat.LONG);
    dfa[5] = DateFormat.getDateInstance(DateFormat.FULL);

    for (DateFormat df : dfa) {
      System.out.println(df.format(d1));
    }
  }
}
08/09/01 6:46 PM
8-Sep-2001
08/09/01
8-Sep-2001
September 8, 2001
Saturday, September 8, 2001








8.26.Date
8.26.1.How Date, GregorianCalendar, and TimeZone objects are created and how to use their methods to access date/time information.
8.26.2.Get the current date and time.
8.26.3.Date and time calculations, and format date in different locales with different date styles.
8.26.4.Find out how long it took for a trillion milliseconds to pass, starting at January 1, 1970
8.26.5.The Calendar Class
8.26.6.The DateFormat Class
8.26.7.DateFormat.format(), DateFormat.parse()