public class SimpleDateFormat extends DateFormat
DateFormat.Field
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
Constructor and Description |
---|
SimpleDateFormat() |
SimpleDateFormat(String pattern) |
SimpleDateFormat(String pattern,
DateFormatSymbols dfs) |
SimpleDateFormat(String pattern,
Locale loc) |
Modifier and Type | Method and Description |
---|---|
void |
applyLocalizedPattern(String pattern) |
void |
applyPattern(String pattern) |
Object |
clone()
Returns a new instance of
DateFormat with the same properties. |
boolean |
equals(Object o)
Compares this date format with the specified object and indicates if they
are equal.
|
StringBuffer |
format(Date date,
StringBuffer dest,
FieldPosition pos)
Formats the specified date as a string using the pattern of this date
format and appends the string to the specified string buffer.
|
Date |
get2DigitYearStart() |
DateFormatSymbols |
getDateFormatSymbols() |
int |
hashCode()
The (default) object hashcode: for transient objects this is simply the
address of the instance in memory, for persistent objects it is the
address at which the instance was first created (maybe in a previous
activation of the VM).
|
Date |
parse(String str,
ParsePosition pos)
Parses a date from the specified string starting at the index specified
by
position . |
void |
set2DigitYearStart(Date date) |
void |
setDateFormatSymbols(DateFormatSymbols dfs) |
String |
toLocalizedPattern() |
String |
toPattern() |
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
format, formatToCharacterIterator, parseObject
public SimpleDateFormat()
public SimpleDateFormat(String pattern)
public SimpleDateFormat(String pattern, DateFormatSymbols dfs)
public void applyLocalizedPattern(String pattern)
public void applyPattern(String pattern)
public Object clone()
DateFormat
DateFormat
with the same properties.clone
in class DateFormat
DateFormat
.Cloneable
public boolean equals(Object o)
DateFormat
equals
in class DateFormat
o
- the object to compare with this date format.true
if object
is a DateFormat
object and
it has the same properties as this date format; false
otherwise.DateFormat.hashCode()
public StringBuffer format(Date date, StringBuffer dest, FieldPosition pos)
DateFormat
If the field
member of field
contains a value specifying
a format field, then its beginIndex
and endIndex
members
will be updated with the position of the first occurrence of this field
in the formatted text.
format
in class DateFormat
date
- the date to format.dest
- the target string buffer to append the formatted date/time to.pos
- on input: an optional alignment field; on output: the offsets
of the alignment field in the formatted text.public DateFormatSymbols getDateFormatSymbols()
public Date get2DigitYearStart()
public int hashCode()
Object
hashCode
in class DateFormat
public Date parse(String str, ParsePosition pos)
DateFormat
position
. If the string is successfully parsed then the index
of the ParsePosition
is updated to the index following the parsed
text. On error, the index is unchanged and the error index of ParsePosition
is set to the index where the error occurred.
By default, parsing is lenient: If the input is not in the form used by
this object's format method but can still be parsed as a date, then the
parse succeeds. Clients may insist on strict adherence to the format by
calling setLenient(false)
.
parse
in class DateFormat
null
if there is an
error.public void setDateFormatSymbols(DateFormatSymbols dfs)
public void set2DigitYearStart(Date date)
public String toLocalizedPattern()
public String toPattern()