SimpleDateFormatNameSimpleDateFormatSynopsis
DescriptionThe SimpleDateFormat class is a concrete subclass of DateFormat that formats and parses dates and times using a formatting pattern. Typically, you do not need to instantiate SimpleDateFormat yourself. Instead, the factory methods of DateFormat return instances of SimpleDateFormat that are appropriate for particular locales. However, if you need a specialized date and time format, you can instantiate your own SimpleDateFormat using a pattern string. You can also modify the formatting pattern of an existing SimpleDateFormat object using the applyPattern() method. The following symbols are significant in the pattern string.
Symbols that are numeric can be repeated to specify a minimum number of digits. For example, "hh" produces an hour field that is always at least two digits, like "02". Symbols that are textual can be repeated to specify whether the short form or the long form of the text string is used, if there are both short and long forms. If four or more symbols are specified, the long form is used; otherwise the short form is used. For example, "E" produces a short form of the day of the week, such as "Tue", while "EEEE" produces the long form, such as "Tuesday". For the month of the year, if one or two "M" symbols are used, the field is numeric. If three or more "M" symbols are used, the field is textual. Single quotes can be used to specify literal text that should be included in the formatted output, and any unrecognized symbol is treated as literal text. For example, the following pattern:
hh:mm a 'in the' zzzz 'zone.' produces output like:
02:33 PM in the Eastern Standard Time zone. Internally, the SimpleDataFormat class uses a DateFormatSymbols object to get the date and time strings that are appropriate for a particular locale. If you want to modify these strings, you can get the DateFormatSymbols object by calling getDateFormatSymbols(). Class Summary
public class java.text.SimpleDateFormat extends java.text.DateFormat { // Constructors public SimpleDateFormat(); public SimpleDateFormat(String pattern); public SimpleDateFormat(String pattern, Locale loc); public SimpleDateFormat(String pattern, DateFormatSymbols formatData); // Instance Methods public void applyLocalizedPattern(String pattern); public void applyPattern(String pattern); public Object clone(); public boolean equals(Object obj); public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos); public DateFormatSymbols getDateFormatSymbols(); public int hashCode(); public Date parse(String text, ParsePosition pos); public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols); public String toLocalizedPattern(); public String toPattern(); } ConstructorsSimpleDateFormatpublic SimpleDateFormat()
public SimpleDateFormat(String pattern)
public SimpleDateFormat(String pattern, Locale loc)
public SimpleDateFormat(String pattern, DateFormatSymbols formatData)
Instance MethodsapplyLocalizedPatternpublic void applyLocalizedPattern(String pattern)
applyPatternpublic void applyPattern(String pattern)
clonepublic Object clone()
equalspublic boolean equals(Object obj)
format
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
getDateFormatSymbolspublic DateFormatSymbols getDateFormatSymbols()
hashCodepublic int hashCode()
parsepublic Date parse(String text, ParsePosition pos)
setDateFormatSymbols
public void setDateFormatSymbols( DateFormatSymbols newFormatSymbols)
toLocalizedPatternpublic String toLocalizedPattern()
toPatternpublic String toPattern()
Inherited Methods
See AlsoCalendar, Date, DateFormat, DateFormatSymbols, FieldPosition, Format, Locale, ParsePosition, String, StringBuffer, TimeZone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|