java.text
Class DateFormat
java.lang.Object
|
+--java.text.Format
|
+--java.text.DateFormat
All Implemented Interfaces:
Cloneable, Serializable, Cloneable
Author:- Per Bothner <bothner@cygnus.com>
java.lang.Object | clone()
|
boolean | equals(java.lang.Object obj)
|
java.lang.StringBuffer | format(java.lang.Object obj, java.lang.StringBuffer buf, java.text.FieldPosition pos)
|
java.lang.String | format(java.util.Date date)
|
java.lang.StringBuffer | format(java.util.Date date, java.lang.StringBuffer buf, java.text.FieldPosition pos)
|
static java.util.Locale[] | getAvailableLocales()
|
java.util.Calendar | getCalendar()
|
static java.text.DateFormat | getDateInstance()
|
static java.text.DateFormat | getDateInstance(int style)
|
static java.text.DateFormat | getDateInstance(int style, java.util.Locale loc)
|
static java.text.DateFormat | getDateTimeInstance()
|
static java.text.DateFormat | getDateTimeInstance(int dateStyle, int timeStyle)
|
static java.text.DateFormat | getDateTimeInstance(int dateStyle, int timeStyle, java.util.Locale loc)
|
static java.text.DateFormat | getInstance()
|
java.text.NumberFormat | getNumberFormat()
|
static java.text.DateFormat | getTimeInstance()
|
static java.text.DateFormat | getTimeInstance(int style)
|
static java.text.DateFormat | getTimeInstance(int style, java.util.Locale loc)
|
java.util.TimeZone | getTimeZone()
|
int | hashCode()
|
boolean | isLenient()
|
java.util.Date | parse(java.lang.String source)
|
java.util.Date | parse(java.lang.String source, java.text.ParsePosition pos)
|
java.lang.Object | parseObject(java.lang.String source, java.text.ParsePosition pos)
|
void | setCalendar(java.util.Calendar calendar)
|
void | setLenient(boolean lenient)
|
void | setNumberFormat(java.text.NumberFormat numberFormat)
|
void | setTimeZone(java.util.TimeZone timeZone)
|
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:- Per Bothner <bothner@cygnus.com>
numberFormat
protected NumberFormat numberFormat
DateFormat
protected DateFormat()
This method initializes a new instance of DateFormat
.
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:
- Is not
null
.
- Is an instance of
DateFormat
.
- Has the same calendar and numberFormat field values as this object.
Parameters:
Returns:
true
if the specified object is equal to this object,
false
otherwise.
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:
- The
StringBuffer
supplied on input, with the
formatted date/time appended.
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:
- The
StringBuffer
supplied on input, with the
formatted date/time appended.
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:
- The
Calendar
being used by this object.
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:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
getNumberFormat
public NumberFormat getNumberFormat()
This method returns the NumberFormat
object being used
by this object to parse/format time values.
Returns:
- The
NumberFormat
in use by this object.
getTimeInstance
public static final DateFormat getTimeInstance()
This method returns an instance of DateFormat
that will
format using the default formatting style for times.
Returns:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
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:
- A new
DateFormat
instance.
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:
- A hash value for this object.
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:
true
if date/time parsing is lenient,
false
otherwise.
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:
- The parsed date, or
null
if the string cannot
be parsed.
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:
- The parsed date, or
null
if the string cannot
be parsed.
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:
DateFormat
.