Build 1.0_r1(from source)

java.text
Class SimpleDateFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.DateFormat
          extended by java.text.SimpleDateFormat
All Implemented Interfaces:
Serializable, Cloneable

public class SimpleDateFormat
extends DateFormat

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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.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()
          Returns 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()
          Returns the Date which is the start of the one hundred year period for two digits year values.
 DateFormatSymbols getDateFormatSymbols()
          Returns the DateFormatSymbols used by this SimpleDateFormat.
 int hashCode()
          Returns 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()
          Returns the pattern of this SimpleDateFormat using localized pattern characters.
 String toPattern()
          Returns 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, getStyleName, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
 
Methods inherited from class java.text.Format
convertPattern, format, getBundle, parseObject, upTo, upToWithQuotes
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDateFormat

public SimpleDateFormat()
Constructs a new SimpleDateFormat for formatting and parsing dates and times in the SHORT style for the default Locale.


SimpleDateFormat

public SimpleDateFormat(String pattern)
Constructs a new SimpleDateFormat using the specified non-localized pattern and the DateFormatSymbols and Calendar for the default Locale.

Parameters:
pattern - the pattern
Throws:
NullPointerException - if a null value of pattern is supplied.
IllegalArgumentException - if pattern is not considered to be useable by this formatter.

SimpleDateFormat

public SimpleDateFormat(String template,
                        DateFormatSymbols value)
Constructs a new SimpleDateFormat using the specified non-localized pattern and DateFormatSymbols and the Calendar for the default Locale.

Parameters:
template - the pattern
value - the DateFormatSymbols
Throws:
NullPointerException - if the pattern is null
IllegalArgumentException - if the pattern is invalid

SimpleDateFormat

public SimpleDateFormat(String template,
                        Locale locale)
Constructs a new SimpleDateFormat using the specified non-localized pattern and the DateFormatSymbols and Calendar for the specified Locale.

Parameters:
template - the pattern
locale - the Locale
Throws:
NullPointerException - if the pattern is null
IllegalArgumentException - if the pattern is invalid
Method Detail

applyLocalizedPattern

public void applyLocalizedPattern(String template)
Changes the pattern of this SimpleDateFormat to the specified pattern which uses localized pattern characters.

Parameters:
template - the localized pattern

applyPattern

public void applyPattern(String template)
Changes the pattern of this SimpleDateFormat to the specified pattern which uses non-localized pattern characters.

Parameters:
template - the non-localized pattern
Throws:
NullPointerException - if the pattern is null
IllegalArgumentException - if the pattern is invalid

clone

public Object clone()
Returns a new SimpleDateFormat with the same pattern and properties as this SimpleDateFormat.

Overrides:
clone in class DateFormat
Returns:
a shallow copy of this SimpleDateFormat
See Also:
Cloneable

equals

public boolean equals(Object object)
Compares the specified object to this SimpleDateFormat and answer if they are equal. The object must be an instance of SimpleDateFormat and have the same DateFormat properties, pattern, DateFormatSymbols, and creation year.

Overrides:
equals in class DateFormat
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this SimpleDateFormat, false otherwise
See Also:
hashCode()

formatToCharacterIterator

public AttributedCharacterIterator formatToCharacterIterator(Object object)
Formats the specified object using the rules of this SimpleDateFormat and returns an AttributedCharacterIterator with the formatted Date and attributes.

Overrides:
formatToCharacterIterator in class Format
Parameters:
object - the object to format
Returns:
an AttributedCharacterIterator with the formatted date and attributes
Throws:
NullPointerException - when the object is null
IllegalArgumentException - when the object cannot be formatted by this Format

format

public StringBuffer format(Date date,
                           StringBuffer buffer,
                           FieldPosition field)
Formats the specified Date into the specified StringBuffer using the pattern of this SimpleDateFormat. If the field specified by the FieldPosition is formatted, set the begin and end index of the formatted field in the FieldPosition.

Specified by:
format in class DateFormat
Parameters:
date - the Date to format
buffer - the StringBuffer
field - the FieldPosition
Returns:
the StringBuffer parameter buffer
Throws:
IllegalArgumentException - when there are invalid characters in the pattern

get2DigitYearStart

public Date get2DigitYearStart()
Returns the Date which is the start of the one hundred year period for two digits year values.

Returns:
a Date

getDateFormatSymbols

public DateFormatSymbols getDateFormatSymbols()
Returns the DateFormatSymbols used by this SimpleDateFormat.

Returns:
a DateFormatSymbols

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Overrides:
hashCode in class DateFormat
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

parse

public Date parse(String string,
                  ParsePosition position)
Parse a Date from the specified String starting at the index specified by the ParsePosition. If the string is successfully parsed, the index of the ParsePosition is updated to the index following the parsed text.

Specified by:
parse in class DateFormat
Parameters:
string - the String to parse according to the pattern of this SimpleDateFormat
position - 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
Returns:
the Date resulting from the parse, or null if there is an error
Throws:
IllegalArgumentException - when there are invalid characters in the pattern

set2DigitYearStart

public void set2DigitYearStart(Date date)
Sets the Date which is the start of the one hundred year period for two digits year values.

Parameters:
date - the Date

setDateFormatSymbols

public void setDateFormatSymbols(DateFormatSymbols value)
Sets the DateFormatSymbols used by this SimpleDateFormat.

Parameters:
value - the DateFormatSymbols

toLocalizedPattern

public String toLocalizedPattern()
Returns the pattern of this SimpleDateFormat using localized pattern characters.

Returns:
the localized pattern

toPattern

public String toPattern()
Returns the pattern of this SimpleDateFormat using non-localized pattern characters.

Returns:
the non-localized pattern

Build 1.0_r1(from source)

Please submit a feedback, bug or feature