Constants from DateFormat

TypeFieldSummary
static intAM_PM_FIELDAM_PM field alignment.
static intDATE_FIELDDATE field alignment.
static intDAY_OF_WEEK_FIELDDAY_OF_WEEK field alignment.
static intDAY_OF_WEEK_IN_MONTH_FIELDDAY_OF_WEEK_IN_MONTH field alignment.
static intDAY_OF_YEAR_FIELDDAY_OF_YEAR field alignment.
static intERA_FIELDERA field alignment.
static intHOUR_OF_DAY0_FIELDzero-based HOUR_OF_DAY field alignment.
static intHOUR_OF_DAY1_FIELDone-based HOUR_OF_DAY field alignment.
static intHOUR0_FIELDzero-based HOUR field alignment.
static intHOUR1_FIELDone-based HOUR field alignment.
static intMILLISECOND_FIELDMILLISECOND field alignment.
static intMINUTE_FIELDMINUTE field alignment.
static intMONTH_FIELDMONTH field alignment.
static intSECOND_FIELDSECOND field alignment.
static intTIMEZONE_FIELDTIMEZONE field alignment.
static intWEEK_OF_MONTH_FIELDWEEK_OF_MONTH field alignment.
static intWEEK_OF_YEAR_FIELDWEEK_OF_YEAR field alignment.
static intYEAR_FIELDYEAR field alignment.

TypeFieldSummary
static intDEFAULTConstant for default style pattern.
static intFULLConstant for full style pattern.
static intLONGConstant for long style pattern.
static intMEDIUMConstant for medium style pattern.
static intSHORTConstant for short style pattern.

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

public class Main{

  public static void main(String args[]) {
    Date date = new Date();
    DateFormat df;

    df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.JAPAN);
    System.out.println("Japan:" + df.format(date));

    df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.KOREA);
    System.out.println("Korea:" + df.format(date));

    df = DateFormat.getDateInstance(DateFormat.LONG, Locale.UK);
    System.out.println("United Kingdom:" + df.format(date));

    df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
    System.out.println("United States:" + df.format(date));
  }
}

The output:


Japan:10/10/30
Korea:2010. 10. 30
United Kingdom:30 October 2010
United States:Saturday, October 30, 2010
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.