java.text
Class SimpleDateFormat
java.lang.Object
|
+--java.text.Format
|
+--java.text.DateFormat
|
+--java.text.SimpleDateFormat
SimpleDateFormat provides convenient methods for parsing and formatting
dates using Gregorian calendars (see java.util.GregorianCalendar).
SimpleDateFormat
public SimpleDateFormat()
Constructs a SimpleDateFormat using the default pattern for
the default locale.
SimpleDateFormat
public SimpleDateFormat(java.lang.String pattern)
Creates a date formatter using the specified pattern, with the default
DateFormatSymbols for the default locale.
Parameters:
SimpleDateFormat
public SimpleDateFormat(java.lang.String pattern, java.text.DateFormatSymbols formatData)
Creates a date formatter using the specified pattern. The
specified DateFormatSymbols will be used when formatting.
Parameters:
SimpleDateFormat
public SimpleDateFormat(java.lang.String pattern, java.util.Locale locale)
Creates a date formatter using the specified pattern, with the default
DateFormatSymbols for the given locale.
Parameters:
applyLocalizedPattern
public void applyLocalizedPattern(java.lang.String pattern)
This method sets the formatting pattern that should be used by this
object. This string is localized.
Parameters:
applyPattern
public void applyPattern(java.lang.String pattern)
This method sets the formatting pattern that should be used by this
object. This string is not localized.
Parameters:
equals
public boolean equals(java.lang.Object o)
This methods tests whether the specified object is equal to this
object. This will be true if and only if the specified object:
- Is not
null
.
- Is an instance of
SimpleDateFormat
.
- Is equal to this object at the superclass (i.e.,
DateFormat
)
level.
- Has the same formatting pattern.
- Is using the same formatting symbols.
- Is using the same century for two digit years.
Parameters:
Returns:
true
if the specified object is equal to this object,
false
otherwise.
format
public StringBuffer format(java.util.Date date, java.lang.StringBuffer buffer, java.text.FieldPosition pos)
Formats the date input according to the format string in use,
appending to the specified StringBuffer. The input StringBuffer
is returned as output for convenience.
Parameters:
get2DigitYearStart
public Date get2DigitYearStart()
Returns the start of the century used for two digit years.
Returns:
- A
Date
representing the start of the century
for two digit years.
getDateFormatSymbols
public DateFormatSymbols getDateFormatSymbols()
This method returns the format symbol information used for parsing
and formatting dates.
Returns:
parse
public Date parse(java.lang.String dateStr, java.text.ParsePosition pos)
This method parses the specified string into a date.
Parameters:
Returns:
- The parsed date, or
null
if the string cannot be
parsed.
set2DigitYearStart
public void set2DigitYearStart(java.util.Date date)
Sets the start of the century used for two digit years.
Parameters:
setDateFormatSymbols
public void setDateFormatSymbols(java.text.DateFormatSymbols formatData)
This method sets the format symbols information used for parsing
and formatting dates.
Parameters:
toLocalizedPattern
public String toLocalizedPattern()
This method returns a string with the formatting pattern being used
by this object. This string is localized.
Returns:
toPattern
public String toPattern()
This method returns a string with the formatting pattern being used
by this object. This string is unlocalized.
Returns:
toString
public String toString()