Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.text

Class DateFormat

java.lang.Object
|
+--java.text.Format
   |
   +--java.text.DateFormat

All Implemented Interfaces:

Cloneable, Serializable, Cloneable


public abstract class DateFormat

extends Format

implements Cloneable

Author:

Field Summary

static intAM_PM_FIELD

static intDATE_FIELD

static intDAY_OF_WEEK_FIELD

static intDAY_OF_WEEK_IN_MONTH_FIELD

static intDAY_OF_YEAR_FIELD

static intDEFAULT

static intERA_FIELD

static intFULL

static intHOUR0_FIELD

static intHOUR1_FIELD

static intHOUR_OF_DAY0_FIELD

static intHOUR_OF_DAY1_FIELD

static intLONG

static intMEDIUM

static intMILLISECOND_FIELD

static intMINUTE_FIELD

static intMONTH_FIELD

static intSECOND_FIELD

static intSHORT

static intTIMEZONE_FIELD

static intWEEK_OF_MONTH_FIELD

static intWEEK_OF_YEAR_FIELD

static intYEAR_FIELD

java.util.Calendarcalendar

java.text.NumberFormatnumberFormat

Constructor Summary

DateFormat()

This method initializes a new instance of DateFormat.

Method Summary

java.lang.Objectclone()

This method returns a copy of this object.
booleanequals(java.lang.Object obj)

This method tests this object for equality against the specified object.
java.lang.StringBufferformat(java.lang.Object obj, java.lang.StringBuffer buf, java.text.FieldPosition pos)

This method formats the specified Object into a date string and appends it to the specified StringBuffer.
java.lang.Stringformat(java.util.Date date)

Formats the date argument according to the pattern specified.
java.lang.StringBufferformat(java.util.Date date, java.lang.StringBuffer buf, java.text.FieldPosition pos)

This method formats a Date into a string and appends it to the specified StringBuffer.
static java.util.Locale[]getAvailableLocales()

This method returns a list of available locales supported by this class.
java.util.CalendargetCalendar()

This method returns the Calendar object being used by this object to parse/format datetimes.
static java.text.DateFormatgetDateInstance()

This method returns an instance of DateFormat that will format using the default formatting style for dates.
static java.text.DateFormatgetDateInstance(int style)

This method returns an instance of DateFormat that will format using the specified formatting style for dates.
static java.text.DateFormatgetDateInstance(int style, java.util.Locale loc)

This method returns an instance of DateFormat that will format using the specified formatting style for dates.
static java.text.DateFormatgetDateTimeInstance()

This method returns a new instance of DateFormat that formats both dates and times using the SHORT style.
static java.text.DateFormatgetDateTimeInstance(int dateStyle, int timeStyle)

This method returns a new instance of DateFormat that formats both dates and times using the DEFAULT style.
static java.text.DateFormatgetDateTimeInstance(int dateStyle, int timeStyle, java.util.Locale loc)

This method returns a new instance of DateFormat that formats both dates and times using the specified styles.
static java.text.DateFormatgetInstance()

This method returns a new instance of DateFormat that formats both dates and times using the SHORT style.
java.text.NumberFormatgetNumberFormat()

This method returns the NumberFormat object being used by this object to parse/format time values.
static java.text.DateFormatgetTimeInstance()

This method returns an instance of DateFormat that will format using the default formatting style for times.
static java.text.DateFormatgetTimeInstance(int style)

This method returns an instance of DateFormat that will format using the specified formatting style for times.
static java.text.DateFormatgetTimeInstance(int style, java.util.Locale loc)

This method returns an instance of DateFormat that will format using the specified formatting style for times.
java.util.TimeZonegetTimeZone()

This method returns the TimeZone object being used by this instance.
inthashCode()

This method returns a hash value for this object.
booleanisLenient()

This method indicates whether or not the parsing of date and time values should be done in a lenient value.
java.util.Dateparse(java.lang.String source)

This method parses the specified date/time string.
java.util.Dateparse(java.lang.String source, java.text.ParsePosition pos)

This method parses the specified String into a Date.
java.lang.ObjectparseObject(java.lang.String source, java.text.ParsePosition pos)

This method is identical to parse(String, ParsePosition), but returns its result as an Object instead of a Date.
voidsetCalendar(java.util.Calendar calendar)

This method specified the Calendar that should be used by this object to parse/format datetimes.
voidsetLenient(boolean lenient)

This method specifies whether or not this object should be lenient in the syntax it accepts while parsing date/time values.
voidsetNumberFormat(java.text.NumberFormat numberFormat)

This method specifies the NumberFormat object that should be used by this object to parse/format times.
voidsetTimeZone(java.util.TimeZone timeZone)

This method sets the time zone that should be used by this object.

Field Details

AM_PM_FIELD

public static final int AM_PM_FIELD


DATE_FIELD

public static final int DATE_FIELD


DAY_OF_WEEK_FIELD

public static final int DAY_OF_WEEK_FIELD


DAY_OF_WEEK_IN_MONTH_FIELD

public static final int DAY_OF_WEEK_IN_MONTH_FIELD


DAY_OF_YEAR_FIELD

public static final int DAY_OF_YEAR_FIELD


DEFAULT

public static final int DEFAULT


ERA_FIELD

public static final int ERA_FIELD


FULL

public static final int FULL


HOUR0_FIELD

public static final int HOUR0_FIELD


HOUR1_FIELD

public static final int HOUR1_FIELD


HOUR_OF_DAY0_FIELD

public static final int HOUR_OF_DAY0_FIELD


HOUR_OF_DAY1_FIELD

public static final int HOUR_OF_DAY1_FIELD


LONG

public static final int LONG


MEDIUM

public static final int MEDIUM


MILLISECOND_FIELD

public static final int MILLISECOND_FIELD


MINUTE_FIELD

public static final int MINUTE_FIELD


MONTH_FIELD

public static final int MONTH_FIELD


SECOND_FIELD

public static final int SECOND_FIELD


SHORT

public static final int SHORT


TIMEZONE_FIELD

public static final int TIMEZONE_FIELD


WEEK_OF_MONTH_FIELD

public static final int WEEK_OF_MONTH_FIELD


WEEK_OF_YEAR_FIELD

public static final int WEEK_OF_YEAR_FIELD


YEAR_FIELD

public static final int YEAR_FIELD


calendar

protected Calendar calendar

Author:

numberFormat

protected NumberFormat numberFormat


Constructor Details

DateFormat

protected DateFormat()

This method initializes a new instance of DateFormat.


Method Details

clone

public Object clone()

This method returns a copy of this object.

Returns:


equals

public boolean equals(java.lang.Object obj)

This method tests this object for equality against the specified object. The two objects will be considered equal if an only if the specified object:

Parameters:

Returns:


format

public final StringBuffer format(java.lang.Object obj, java.lang.StringBuffer buf, java.text.FieldPosition pos)

This method formats the specified Object into a date string and appends it to the specified StringBuffer. The specified object must be an instance of Number or Date or an IllegalArgumentException will be thrown.

Parameters:

Returns:


format

public final String format(java.util.Date date)

Formats the date argument according to the pattern specified.

Parameters:


format

public StringBuffer format(java.util.Date date, java.lang.StringBuffer buf, java.text.FieldPosition pos)

This method formats a Date into a string and appends it to the specified StringBuffer.

Parameters:

Returns:


getAvailableLocales

public static Locale[] getAvailableLocales()

This method returns a list of available locales supported by this class.


getCalendar

public Calendar getCalendar()

This method returns the Calendar object being used by this object to parse/format datetimes.

Returns:

See Also:


getDateInstance

public static final DateFormat getDateInstance()

This method returns an instance of DateFormat that will format using the default formatting style for dates.

Returns:


getDateInstance

public static final DateFormat getDateInstance(int style)

This method returns an instance of DateFormat that will format using the specified formatting style for dates.

Parameters:

Returns:


getDateInstance

public static final DateFormat getDateInstance(int style, java.util.Locale loc)

This method returns an instance of DateFormat that will format using the specified formatting style for dates. The specified localed will be used in place of the default.

Parameters:

Returns:


getDateTimeInstance

public static final DateFormat getDateTimeInstance()

This method returns a new instance of DateFormat that formats both dates and times using the SHORT style.

Returns:


getDateTimeInstance

public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle)

This method returns a new instance of DateFormat that formats both dates and times using the DEFAULT style.

Parameters:

Returns:


getDateTimeInstance

public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle, java.util.Locale loc)

This method returns a new instance of DateFormat that formats both dates and times using the specified styles.

Parameters:

Returns:


getInstance

public static final DateFormat getInstance()

This method returns a new instance of DateFormat that formats both dates and times using the SHORT style.

Returns:


getNumberFormat

public NumberFormat getNumberFormat()

This method returns the NumberFormat object being used by this object to parse/format time values.

Returns:


getTimeInstance

public static final DateFormat getTimeInstance()

This method returns an instance of DateFormat that will format using the default formatting style for times.

Returns:


getTimeInstance

public static final DateFormat getTimeInstance(int style)

This method returns an instance of DateFormat that will format using the specified formatting style for times.

Parameters:

Returns:


getTimeInstance

public static final DateFormat getTimeInstance(int style, java.util.Locale loc)

This method returns an instance of DateFormat that will format using the specified formatting style for times. The specified localed will be used in place of the default.

Parameters:

Returns:


getTimeZone

public TimeZone getTimeZone()

This method returns the TimeZone object being used by this instance.

Returns:


hashCode

public int hashCode()

This method returns a hash value for this object.

Returns:


isLenient

public boolean isLenient()

This method indicates whether or not the parsing of date and time values should be done in a lenient value.

Returns:


parse

public Date parse(java.lang.String source)

This method parses the specified date/time string.

Parameters:

Returns:

Throws:


parse

public Date parse(java.lang.String source, java.text.ParsePosition pos)

This method parses the specified String into a Date. The pos argument contains the starting parse position on method entry and the ending parse position on method exit.

Parameters:

Returns:


parseObject

public Object parseObject(java.lang.String source, java.text.ParsePosition pos)

This method is identical to parse(String, ParsePosition), but returns its result as an Object instead of a Date.

Parameters:

Returns:


setCalendar

public void setCalendar(java.util.Calendar calendar)

This method specified the Calendar that should be used by this object to parse/format datetimes.

Parameters:

See Also:


setLenient

public void setLenient(boolean lenient)

This method specifies whether or not this object should be lenient in the syntax it accepts while parsing date/time values.

Parameters:


setNumberFormat

public void setNumberFormat(java.text.NumberFormat numberFormat)

This method specifies the NumberFormat object that should be used by this object to parse/format times.

Parameters:


setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)

This method sets the time zone that should be used by this object.

Parameters: