DateFormatNameDateFormatSynopsis
DescriptionThe DateFormat class formats and parses dates and times in a locale-specific manner. DateFormat is an abstract class, but it provides factory methods that return useful instances of DateFormat subclasses. These factory methods come in three groups:
Certain of these factory methods allow you to specify the style, or length, of the resulting date and time strings. The interpretation of the style parameter is locale-specific. For the locale Locale.US, the styles and their results are as follows:
There is also a DEFAULT style, which is equivalent to MEDIUM. The DateFormat class defines a number of field constants that represent the various fields in formatted date and time strings. These field constants can create FieldPosition objects. Class Summary
public abstract class java.text.DateFormat extends java.text.Format implements java.lang.Cloneable { // Constants public static final int AM_PM_FIELD; public static final int DATE_FIELD; public static final int DAY_OF_WEEK_FIELD; public static final int DAY_OF_WEEK_IN_MONTH_FIELD; public static final int DAY_OF_YEAR_FIELD; public static final int DEFAULT; public static final int ERA_FIELD; public static final int FULL; public static final int HOUR0_FIELD; public static final int HOUR1_FIELD; public static final int HOUR_OF_DAY0_FIELD; public static final int HOUR_OF_DAY1_FIELD; public static final int LONG; public static final int MEDIUM; public static final int MILLISECOND_FIELD; public static final int MINUTE_FIELD; public static final int MONTH_FIELD; public static final int SECOND_FIELD; public static final int SHORT; public static final int TIMEZONE_FIELD; public static final int WEEK_OF_MONTH_FIELD; public static final int WEEK_OF_YEAR_FIELD; public static final int YEAR_FIELD; // Variables protected Calendar calendar; protected NumberFormat numberFormat; // Constructors protected DateFormat(); // Class Methods public static Locale[] getAvailableLocales(); public static final DateFormat getDateInstance(); public static final DateFormat getDateInstance(int style); public static final DateFormat getDateInstance(int style, Locale aLocale); public static final DateFormat getDateTimeInstance(); public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle); public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale aLocale); public static final DateFormat getInstance(); public static final DateFormat getTimeInstance(); public static final DateFormat getTimeInstance(int style); public static final DateFormat getTimeInstance(int style, Locale aLocale); // Instance Methods public Object clone(); public boolean equals(Object obj); public final String format(Date date); public final StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition); public abstract StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition); public Calendar getCalendar(); public NumberFormat getNumberFormat(); public TimeZone getTimeZone(); public int hashCode(); public boolean isLenient(); public Date parse(String text); public abstract Date parse(String text, ParsePosition pos); public Object parseObject(String source, ParsePosition pos); public void setCalendar(Calendar newCalendar); public void setLenient(boolean lenient); public void setNumberFormat(NumberFormat newNumberFormat); public void setTimeZone(TimeZone zone); } ConstantsAM_PM_FIELDpublic final static int AM_PM_FIELD
DATE_FIELDpublic final static int DATE_FIELD
DAY_OF_WEEK_FIELDpublic final static int DAY_OF_WEEK_FIELD
DAY_OF_WEEK_IN_MONTH_FIELDpublic final static int DAY_OF_WEEK_IN_MONTH_FIELD
DAY_OF_YEAR_FIELDpublic final static int DAY_OF_YEAR_FIELD
DEFAULTpublic final static int DEFAULT
ERA_FIELDpublic final static int ERA_FIELD
FULLpublic final static int FULL
HOUR0_FIELDpublic final static int HOUR0_FIELD
HOUR1_FIELDpublic final static int HOUR1_FIELD
HOUR_OF_DAY0_FIELDpublic final static int HOUR_OF_DAY0_FIELD
HOUR_OF_DAY1_FIELDpublic final static int HOUR_OF_DAY1_FIELD
LONGpublic final static int LONG
MEDIUMpublic final static int MEDIUM
MILLISECOND_FIELDpublic final static int MILLISECOND_FIELD
MINUTE_FIELDpublic final static int MINUTE_FIELD
MONTH_FIELDpublic final static int MONTH_FIELD
SECOND_FIELDpublic final static int SECOND_FIELD
SHORTpublic final static int SHORT
TIMEZONE_FIELDpublic final static int TIMEZONE_FIELD
WEEK_OF_MONTH_FIELDpublic final static int WEEK_OF_MONTH_FIELD
WEEK_OF_YEAR_FIELDpublic final static int WEEK_OF_YEAR_FIELD
YEAR_FIELDpublic final static int YEAR_FIELD
Variablescalendarprotected Calendar calendar
numberFormatprotected NumberFormat numberFormat
ConstructorsDateFormatprotected DateFormat()
Class MethodsgetAvailableLocalespublic static Locale[] getAvailableLocales()
getDateInstancepublic static final DateFormat getDateInstance()
public static final DateFormat getDateInstance(int style)
public static final DateFormat getDateInstance(int style, Locale aLocale)
getDateTimeInstancepublic static final DateFormat getDateTimeInstance()
public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale aLocale)
getInstancepublic static final DateFormat getInstance()
getTimeInstancepublic static final DateFormat getTimeInstance()
public static final DateFormat getTimeInstance(int style)
public static final DateFormat getTimeInstance(int style, Locale aLocale)
Instance Methodsclonepublic Object clone()
equalspublic boolean equals(Object obj)
formatpublic final String format(Date date)
public final StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
public abstract StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
getCalendarpublic Calendar getCalendar()
getNumberFormatpublic NumberFormat getNumberFormat()
getTimeZonepublic TimeZone getTimeZone()
hashCodepublic int hashCode()
isLenientpublic boolean isLenient()
parsepublic Date parse(String text) throws ParseException
public abstract Date parse(String text, ParsePosition pos)
parseObjectpublic Object parseObject(String source, ParsePosition pos)
setCalendarpublic void setCalendar(Calendar newCalendar)
setLenientpublic void setLenient(boolean lenient)
setNumberFormatpublic void setNumberFormat(NumberFormat newNumberFormat)
setTimeZonepublic void setTimeZone(TimeZone zone)
Inherited Methods
See AlsoCalendar, Cloneable, Date, FieldPosition, Format, Locale, NumberFormat, ParsePosition, String, StringBuffer, TimeZone | ||||||||||||||||||||||||
|