Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.text.Format
java.text.DateFormat
Nested Class Summary | |
static class |
Nested classes/interfaces inherited from class java.text.Format | |
Format.Field |
Field Summary | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int | |
static int |
|
static int | |
static int |
|
static int |
|
static int |
|
static int |
|
static int | |
static int | |
static int |
|
static int |
|
static int |
|
static int |
|
static int | |
static int |
|
static int |
|
static int |
|
static int |
|
protected Calendar | |
protected NumberFormat |
Constructor Summary | |
|
Method Summary | |
Object |
|
boolean | |
StringBuffer |
|
String | |
abstract StringBuffer |
|
static Locale[] |
|
Calendar |
|
static DateFormat |
|
static DateFormat |
|
static DateFormat |
|
static DateFormat |
|
static DateFormat |
|
static DateFormat |
|
static DateFormat |
|
NumberFormat |
|
static DateFormat |
|
static DateFormat |
|
static DateFormat |
|
TimeZone |
|
int |
|
boolean |
|
Date | |
abstract Date |
|
Object |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.text.Format | |
clone , format , format , formatToCharacterIterator , parseObject , parseObject |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int AM_PM_FIELD
Represents the position of the am/pm pattern character in the array of localized pattern characters. In the U.S. locale, this is 'a'.
- Field Value:
- 14
public static final int DATE_FIELD
Represents the position of the date or day of the month pattern character in the array of localized pattern characters. In the U.S. locale, this is 'd'.
- Field Value:
- 3
public static final int DAY_OF_WEEK_FIELD
Represents the position of the day of the week pattern character in the array of localized pattern characters. In the U.S. locale, this is 'E'.
- Field Value:
- 9
public static final int DAY_OF_WEEK_IN_MONTH_FIELD
Represents the position of the day of the week in the month pattern character in the array of localized pattern characters. In the U.S. locale, this is 'F'.
- Field Value:
- 11
public static final int DAY_OF_YEAR_FIELD
Represents the position of the day of the year pattern character in the array of localized pattern characters. In the U.S. locale, this is 'D'.
- Field Value:
- 10
public static final int ERA_FIELD
Represents the position of the era pattern character in the array of localized pattern characters. For example, 'AD' is an era used in the Gregorian calendar system. In the U.S. locale, this is 'G'.
- Field Value:
- 0
public static final int HOUR0_FIELD
Represents the position of the 12 hour pattern character in the array of localized pattern characters. In the U.S. locale, this is 'K'. This field numbers hours from 0 to 11.
- Field Value:
- 16
public static final int HOUR1_FIELD
Represents the position of the 12 hour pattern character in the array of localized pattern characters. In the U.S. locale, this is 'h'. This field numbers hours from 1 to 12.
- Field Value:
- 15
public static final int HOUR_OF_DAY0_FIELD
Represents the position of the 24 hour pattern character in the array of localized pattern characters. In the U.S. locale, this is 'H'. This field numbers hours from 0 to 23.
- Field Value:
- 5
public static final int HOUR_OF_DAY1_FIELD
Represents the position of the 24 hour pattern character in the array of localized pattern characters. In the U.S. locale, this is 'k'. This field numbers hours from 1 to 24.
- Field Value:
- 4
public static final int MILLISECOND_FIELD
Represents the position of the millisecond pattern character in the array of localized pattern characters. In the U.S. locale, this is 'S'.
- Field Value:
- 8
public static final int MINUTE_FIELD
Represents the position of the minute pattern character in the array of localized pattern characters. In the U.S. locale, this is 'm'.
- Field Value:
- 6
public static final int MONTH_FIELD
Represents the position of the month pattern character in the array of localized pattern characters. In the U.S. locale, this is 'M'.
- Field Value:
- 2
public static final int SECOND_FIELD
Represents the position of the second pattern character in the array of localized pattern characters. In the U.S. locale, this is 's'.
- Field Value:
- 7
public static final int TIMEZONE_FIELD
Represents the position of the generic timezone pattern character in the array of localized pattern characters. In the U.S. locale, this is 'z'.
- Field Value:
- 17
public static final int WEEK_OF_MONTH_FIELD
Represents the position of the week of the month pattern character in the array of localized pattern characters. In the U.S. locale, this is 'W'.
- Field Value:
- 13
public static final int WEEK_OF_YEAR_FIELD
Represents the position of the week of the year pattern character in the array of localized pattern characters. In the U.S. locale, this is 'w'.
- Field Value:
- 12
public static final int YEAR_FIELD
Represents the position of the year pattern character in the array of localized pattern characters. In the U.S. locale, this is 'y'.
- Field Value:
- 1
public Object clone()
This method returns a copy of this object.
- Returns:
- A copy of this object.
public boolean equals(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:
Note that not all properties of the Calendar are relevant for a DateFormat. For formatting only the fact whether or not the TimeZone has the same rules and whether the calendar is lenient and has the same week rules is compared for this implementation of equals. Other properties of the Calendar (such as the time) are not taken into account.
- Is not
null
.- Is an instance of
DateFormat
.- Has equal numberFormat field as this object.
- Has equal (Calendar) TimeZone rules as this object.
- Has equal (Calendar) isLenient results.
- Has equal Calendar first day of week and minimal days in week values.
- Parameters:
obj
- The object to test for equality against.
- Returns:
true
if the specified object is equal to this object,false
otherwise.
public final StringBuffer format(Object obj, StringBuffer buf, FieldPosition pos)
This method formats the specifiedObject
into a date string and appends it to the specifiedStringBuffer
. The specified object must be an instance ofNumber
orDate
or anIllegalArgumentException
will be thrown.
- Parameters:
obj
- TheObject
to format.buf
- TheStringBuffer
to append the resultantString
to.pos
- Is updated to the start and end index of the specified field.
- Returns:
- The
StringBuffer
supplied on input, with the formatted date/time appended.
public final String format(Date date)
Formats the date argument according to the pattern specified.
- Parameters:
date
- The formatted date.
public abstract StringBuffer format(Date date, StringBuffer buf, FieldPosition pos)
This method formats aDate
into a string and appends it to the specifiedStringBuffer
.
- Parameters:
date
- TheDate
value to format.buf
- TheStringBuffer
to append the resultantString
to.pos
- Is updated to the start and end index of the specified field.
- Returns:
- The
StringBuffer
supplied on input, with the formatted date/time appended.
public static Locale[] getAvailableLocales()
This method returns a list of available locales supported by this class.
public Calendar getCalendar()
This method returns theCalendar
object being used by this object to parse/format datetimes.
- Returns:
- The
Calendar
being used by this object.
- See Also:
Calendar
public static final DateFormat getDateInstance()
This method returns an instance ofDateFormat
that will format using the default formatting style for dates.
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getDateInstance(int style)
This method returns an instance ofDateFormat
that will format using the specified formatting style for dates.
- Parameters:
style
- The type of formatting to perform.
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getDateInstance(int style, Locale loc)
This method returns an instance ofDateFormat
that will format using the specified formatting style for dates. The specified localed will be used in place of the default.
- Parameters:
style
- The type of formatting to perform.loc
- The desired locale.
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getDateTimeInstance()
This method returns a new instance ofDateFormat
that formats both dates and times using theSHORT
style.
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
This method returns a new instance ofDateFormat
that formats both dates and times using theDEFAULT
style.
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale loc)
This method returns a new instance ofDateFormat
that formats both dates and times using the specified styles.
- Parameters:
dateStyle
- The desired style for date formatting.timeStyle
- The desired style for time formatting
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getInstance()
This method returns a new instance ofDateFormat
that formats both dates and times using theSHORT
style.
- Returns:
- A new
DateFormat
instance.
public NumberFormat getNumberFormat()
This method returns theNumberFormat
object being used by this object to parse/format time values.
- Returns:
- The
NumberFormat
in use by this object.
public static final DateFormat getTimeInstance()
This method returns an instance ofDateFormat
that will format using the default formatting style for times.
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getTimeInstance(int style)
This method returns an instance ofDateFormat
that will format using the specified formatting style for times.
- Parameters:
style
- The type of formatting to perform.
- Returns:
- A new
DateFormat
instance.
public static final DateFormat getTimeInstance(int style, Locale loc)
This method returns an instance ofDateFormat
that will format using the specified formatting style for times. The specified localed will be used in place of the default.
- Parameters:
style
- The type of formatting to perform.loc
- The desired locale.
- Returns:
- A new
DateFormat
instance.
public TimeZone getTimeZone()
This method returns theTimeZone
object being used by this instance.
- Returns:
- The time zone in use.
public int hashCode()
This method returns a hash value for this object.
- Returns:
- A hash value for this object.
public boolean isLenient()
This method indicates whether or not the parsing of date and time values should be done in a lenient value.
- Returns:
true
if date/time parsing is lenient,false
otherwise.
public Date parse(String source) throws ParseException
This method parses the specified date/time string.
- Parameters:
source
- The string to parse.
- Returns:
- The resultant date.
- Throws:
ParseException
- If the specified string cannot be parsed.
public abstract Date parse(String source, ParsePosition pos)
This method parses the specifiedString
into aDate
. Thepos
argument contains the starting parse position on method entry and the ending parse position on method exit.
- Parameters:
source
- The string to parse.pos
- The starting parse position in entry, the ending parse position on exit.
- Returns:
- The parsed date, or
null
if the string cannot be parsed.
public Object parseObject(String source, ParsePosition pos)
This method is identical toparse(String, ParsePosition)
, but returns its result as anObject
instead of aDate
.
- Overrides:
- parseObject in interface Format
- Parameters:
source
- The string to parse.pos
- The starting parse position in entry, the ending parse position on exit.
- Returns:
- The parsed date, or
null
if the string cannot be parsed.
public void setCalendar(Calendar calendar)
This method specified theCalendar
that should be used by this object to parse/format datetimes.
- Parameters:
calendar
- The newCalendar
for this object.
- See Also:
Calendar
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:
lenient
-true
if parsing should be lenient,false
otherwise.
public void setNumberFormat(NumberFormat numberFormat)
This method specifies theNumberFormat
object that should be used by this object to parse/format times.
- Parameters:
numberFormat
- TheNumberFormat
in use by this object.
public void setTimeZone(TimeZone timeZone)
This method sets the time zone that should be used by this object.
- Parameters:
timeZone
- The new time zone.