|
Final | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Object
|
+--java.text.Format
|
+--java.text.DateFormat
|
+--java.text.SimpleDateFormat
SimpleDateFormat is used to format and parse gregorian calendar dates and times based on a pattern of date and time fields. Each date and time field is specified in the pattern by a specific character. The characters used can be either localized or non-localized. For some fields, which have both numeric and text representations or abbreviated as well as full names, the number of grouped characters specifies how the field is formatted or parsed.
| Nested Class Summary |
|---|
| Nested classes inherited from class java.text.DateFormat |
|---|
DateFormat.Field |
| Nested classes inherited from class java.text.Format |
|---|
Format.Field |
| Field Summary |
|---|
| Fields inherited from class java.text.DateFormat |
|---|
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 Summary | |
|---|---|
SimpleDateFormat()
Constructs a new SimpleDateFormat for formatting and parsing dates and times in the SHORT style for the default Locale. |
|
SimpleDateFormat(String pattern)
Constructs a new SimpleDateFormat using the specified non-localized pattern and the DateFormatSymbols and Calendar for the default Locale. |
|
SimpleDateFormat(String template,
DateFormatSymbols value)
Constructs a new SimpleDateFormat using the specified non-localized pattern and DateFormatSymbols and the Calendar for the default Locale. |
|
SimpleDateFormat(String template,
Locale locale)
Constructs a new SimpleDateFormat using the specified non-localized pattern and the DateFormatSymbols and Calendar for the specified Locale. |
|
| Method Summary | |
|---|---|
void |
applyLocalizedPattern(String template)
Changes the pattern of this SimpleDateFormat to the specified pattern which uses localized pattern characters. |
void |
applyPattern(String template)
Changes the pattern of this SimpleDateFormat to the specified pattern which uses non-localized pattern characters. |
Object |
clone()
Answers a new SimpleDateFormat with the same pattern and properties as this SimpleDateFormat. |
boolean |
equals(Object object)
Compares the specified object to this SimpleDateFormat and answer if they are equal. |
StringBuffer |
format(Date date,
StringBuffer buffer,
FieldPosition field)
Formats the specified Date into the specified StringBuffer using the pattern of this SimpleDateFormat. |
AttributedCharacterIterator |
formatToCharacterIterator(Object object)
Formats the specified object using the rules of this SimpleDateFormat and returns an AttributedCharacterIterator with the formatted Date and attributes. |
Date |
get2DigitYearStart()
Answers the Date which is the start of the one hundred year period for two digits year values. |
DateFormatSymbols |
getDateFormatSymbols()
Answers the DateFormatSymbols used by this SimpleDateFormat. |
int |
hashCode()
Answers an integer hash code for the receiver. |
Date |
parse(String string,
ParsePosition position)
Parse a Date from the specified String starting at the index specified by the ParsePosition. |
void |
set2DigitYearStart(Date date)
Sets the Date which is the start of the one hundred year period for two digits year values. |
void |
setDateFormatSymbols(DateFormatSymbols value)
Sets the DateFormatSymbols used by this SimpleDateFormat. |
String |
toLocalizedPattern()
Answers the pattern of this SimpleDateFormat using localized pattern characters. |
String |
toPattern()
Answers the pattern of this SimpleDateFormat using non-localized pattern characters. |
| Methods inherited from class java.text.DateFormat |
|---|
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone |
| Methods inherited from class java.text.Format |
|---|
format, parseObject |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SimpleDateFormat()
public SimpleDateFormat(String pattern)
pattern - the pattern
NullPointerException - if the pattern is null
IllegalArgumentException - if the pattern is invalidpublic SimpleDateFormat(String template,
DateFormatSymbols value)
template - the patternvalue - the DateFormatSymbols
NullPointerException - if the pattern is null
IllegalArgumentException - if the pattern is invalidpublic SimpleDateFormat(String template,
Locale locale)
template - the patternlocale - the Locale
NullPointerException - if the pattern is null
IllegalArgumentException - if the pattern is invalid| Method Detail |
public void applyLocalizedPattern(String template)
template - the localized patternpublic void applyPattern(String template)
template - the non-localized pattern
NullPointerException - if the pattern is null
IllegalArgumentException - if the pattern is invalidpublic Object clone()
clone in class DateFormatCloneablepublic boolean equals(Object object)
equals in class DateFormatobject - the object to compare with this object
hashCode()public AttributedCharacterIterator formatToCharacterIterator(Object object)
formatToCharacterIterator in class Formatobject - the object to format
IllegalArgumentException - when the object cannot be formatted by this Formatpublic StringBuffer format(Date date,
StringBuffer buffer,
FieldPosition field)
format in class DateFormatdate - the Date to formatbuffer - the StringBufferfield - the FieldPosition
buffer
IllegalArgumentException - when there are invalid characters in the patternpublic Date get2DigitYearStart()
public DateFormatSymbols getDateFormatSymbols()
public int hashCode()
hashCode in class DateFormatequals(java.lang.Object)public Date parse(String string,
ParsePosition position)
parse in class DateFormatstring - the String to parse according to the pattern of this SimpleDateFormatposition - the ParsePosition, updated on return with the index following
the parsed text, or on error the index is unchanged and the
error index is set to the index where the error occurred
IllegalArgumentException - when there are invalid characters in the patternpublic void set2DigitYearStart(Date date)
date - the Datepublic void setDateFormatSymbols(DateFormatSymbols value)
value - the DateFormatSymbolspublic String toLocalizedPattern()
public String toPattern()
|
Final | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||