java.text
Class SimpleDateFormat

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.text.Format sample code for java.text.Format definition code for java.text.Format 
      extended by java.text.DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat 
          extended by java.text.SimpleDateFormat
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

public class SimpleDateFormat
extends DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization.

SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting. However, you are encouraged to create a date-time formatter with either getTimeInstance, getDateInstance, or getDateTimeInstance in DateFormat. Each of these class methods can return a date/time formatter initialized with a default format pattern. You may modify the format pattern using the applyPattern methods as desired. For more information on using these methods, see DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat .

Date and Time Patterns

Date and time formats are specified by date and time pattern strings. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. "''" represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.

The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved):

Letter Date or Time Component Presentation Examples
G Era designator Text AD
y Year Year 1996; 96
M Month in year Month July; Jul; 07
w Week in year Number 27
W Week in month Number 2
D Day in year Number 189
d Day in month Number 10
F Day of week in month Number 2
E Day in week Text Tuesday; Tue
a Am/pm marker Text PM
H Hour in day (0-23) Number 0
k Hour in day (1-24) Number 24
K Hour in am/pm (0-11) Number 0
h Hour in am/pm (1-12) Number 12
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978
z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
Z Time zone RFC 822 time zone -0800
Pattern letters are usually repeated, as their number determines the exact presentation: SimpleDateFormat also supports localized date and time pattern strings. In these strings, the pattern letters described above may be replaced with other, locale dependent, pattern letters. SimpleDateFormat does not deal with the localization of text other than the pattern letters; that's up to the client of the class.

Examples

The following examples show how date and time patterns are interpreted in the U.S. locale. The given date and time are 2001-07-04 12:08:56 local time in the U.S. Pacific Time time zone.
Date and Time Pattern Result
"yyyy.MM.dd G 'at' HH:mm:ss z" 2001.07.04 AD at 12:08:56 PDT
"EEE, MMM d, ''yy" Wed, Jul 4, '01
"h:mm a" 12:08 PM
"hh 'o''clock' a, zzzz" 12 o'clock PM, Pacific Daylight Time
"K:mm a, z" 0:08 PM, PDT
"yyyyy.MMMMM.dd GGG hh:mm aaa" 02001.July.04 AD 12:08 PM
"EEE, d MMM yyyy HH:mm:ss Z" Wed, 4 Jul 2001 12:08:56 -0700
"yyMMddHHmmssZ" 010704120856-0700
"yyyy-MM-dd'T'HH:mm:ss.SSSZ" 2001-07-04T12:08:56.235-0700

Synchronization

Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.

See Also:
Java Tutorial, Calendar sample code for java.util.Calendar definition code for java.util.Calendar , TimeZone sample code for java.util.TimeZone definition code for java.util.TimeZone , DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat , DateFormatSymbols sample code for java.text.DateFormatSymbols definition code for java.text.DateFormatSymbols , Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
DateFormat.Field sample code for java.text.DateFormat.Field definition code for java.text.DateFormat.Field
 
Field Summary
 
Fields inherited from class java.text.DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
AM_PM_FIELD sample code for java.text.DateFormat.AM_PM_FIELD definition code for java.text.DateFormat.AM_PM_FIELD , calendar sample code for java.text.DateFormat.calendar definition code for java.text.DateFormat.calendar , DATE_FIELD sample code for java.text.DateFormat.DATE_FIELD definition code for java.text.DateFormat.DATE_FIELD , DAY_OF_WEEK_FIELD sample code for java.text.DateFormat.DAY_OF_WEEK_FIELD definition code for java.text.DateFormat.DAY_OF_WEEK_FIELD , DAY_OF_WEEK_IN_MONTH_FIELD sample code for java.text.DateFormat.DAY_OF_WEEK_IN_MONTH_FIELD definition code for java.text.DateFormat.DAY_OF_WEEK_IN_MONTH_FIELD , DAY_OF_YEAR_FIELD sample code for java.text.DateFormat.DAY_OF_YEAR_FIELD definition code for java.text.DateFormat.DAY_OF_YEAR_FIELD , DEFAULT sample code for java.text.DateFormat.DEFAULT definition code for java.text.DateFormat.DEFAULT , ERA_FIELD sample code for java.text.DateFormat.ERA_FIELD definition code for java.text.DateFormat.ERA_FIELD , FULL sample code for java.text.DateFormat.FULL definition code for java.text.DateFormat.FULL , HOUR_OF_DAY0_FIELD sample code for java.text.DateFormat.HOUR_OF_DAY0_FIELD definition code for java.text.DateFormat.HOUR_OF_DAY0_FIELD , HOUR_OF_DAY1_FIELD sample code for java.text.DateFormat.HOUR_OF_DAY1_FIELD definition code for java.text.DateFormat.HOUR_OF_DAY1_FIELD , HOUR0_FIELD sample code for java.text.DateFormat.HOUR0_FIELD definition code for java.text.DateFormat.HOUR0_FIELD , HOUR1_FIELD sample code for java.text.DateFormat.HOUR1_FIELD definition code for java.text.DateFormat.HOUR1_FIELD , LONG sample code for java.text.DateFormat.LONG definition code for java.text.DateFormat.LONG , MEDIUM sample code for java.text.DateFormat.MEDIUM definition code for java.text.DateFormat.MEDIUM , MILLISECOND_FIELD sample code for java.text.DateFormat.MILLISECOND_FIELD definition code for java.text.DateFormat.MILLISECOND_FIELD , MINUTE_FIELD sample code for java.text.DateFormat.MINUTE_FIELD definition code for java.text.DateFormat.MINUTE_FIELD , MONTH_FIELD sample code for java.text.DateFormat.MONTH_FIELD definition code for java.text.DateFormat.MONTH_FIELD , numberFormat sample code for java.text.DateFormat.numberFormat definition code for java.text.DateFormat.numberFormat , SECOND_FIELD sample code for java.text.DateFormat.SECOND_FIELD definition code for java.text.DateFormat.SECOND_FIELD , SHORT sample code for java.text.DateFormat.SHORT definition code for java.text.DateFormat.SHORT , TIMEZONE_FIELD sample code for java.text.DateFormat.TIMEZONE_FIELD definition code for java.text.DateFormat.TIMEZONE_FIELD , WEEK_OF_MONTH_FIELD sample code for java.text.DateFormat.WEEK_OF_MONTH_FIELD definition code for java.text.DateFormat.WEEK_OF_MONTH_FIELD , WEEK_OF_YEAR_FIELD sample code for java.text.DateFormat.WEEK_OF_YEAR_FIELD definition code for java.text.DateFormat.WEEK_OF_YEAR_FIELD , YEAR_FIELD sample code for java.text.DateFormat.YEAR_FIELD definition code for java.text.DateFormat.YEAR_FIELD
 
Constructor Summary
SimpleDateFormat sample code for java.text.SimpleDateFormat.SimpleDateFormat() definition code for java.text.SimpleDateFormat.SimpleDateFormat() ()
          Constructs a SimpleDateFormat using the default pattern and date format symbols for the default locale.
SimpleDateFormat sample code for java.text.SimpleDateFormat.SimpleDateFormat(java.lang.String) definition code for java.text.SimpleDateFormat.SimpleDateFormat(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  pattern)
          Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the default locale.
SimpleDateFormat sample code for java.text.SimpleDateFormat.SimpleDateFormat(java.lang.String, java.text.DateFormatSymbols) definition code for java.text.SimpleDateFormat.SimpleDateFormat(java.lang.String, java.text.DateFormatSymbols) (String sample code for java.lang.String definition code for java.lang.String  pattern, DateFormatSymbols sample code for java.text.DateFormatSymbols definition code for java.text.DateFormatSymbols  formatSymbols)
          Constructs a SimpleDateFormat using the given pattern and date format symbols.
SimpleDateFormat sample code for java.text.SimpleDateFormat.SimpleDateFormat(java.lang.String, java.util.Locale) definition code for java.text.SimpleDateFormat.SimpleDateFormat(java.lang.String, java.util.Locale) (String sample code for java.lang.String definition code for java.lang.String  pattern, Locale sample code for java.util.Locale definition code for java.util.Locale  locale)
          Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the given locale.
 
Method Summary
 void applyLocalizedPattern sample code for java.text.SimpleDateFormat.applyLocalizedPattern(java.lang.String) definition code for java.text.SimpleDateFormat.applyLocalizedPattern(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  pattern)
          Applies the given localized pattern string to this date format.
 void applyPattern sample code for java.text.SimpleDateFormat.applyPattern(java.lang.String) definition code for java.text.SimpleDateFormat.applyPattern(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  pattern)
          Applies the given pattern string to this date format.
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for java.text.SimpleDateFormat.clone() definition code for java.text.SimpleDateFormat.clone() ()
          Creates a copy of this SimpleDateFormat.
 boolean equals sample code for java.text.SimpleDateFormat.equals(java.lang.Object) definition code for java.text.SimpleDateFormat.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Compares the given object with this SimpleDateFormat for equality.
 StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer format sample code for java.text.SimpleDateFormat.format(java.util.Date, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.SimpleDateFormat.format(java.util.Date, java.lang.StringBuffer, java.text.FieldPosition) (Date sample code for java.util.Date definition code for java.util.Date  date, StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo, FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
          Formats the given Date into a date/time string and appends the result to the given StringBuffer.
 AttributedCharacterIterator sample code for java.text.AttributedCharacterIterator definition code for java.text.AttributedCharacterIterator formatToCharacterIterator sample code for java.text.SimpleDateFormat.formatToCharacterIterator(java.lang.Object) definition code for java.text.SimpleDateFormat.formatToCharacterIterator(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Formats an Object producing an AttributedCharacterIterator.
 Date sample code for java.util.Date definition code for java.util.Date get2DigitYearStart sample code for java.text.SimpleDateFormat.get2DigitYearStart() definition code for java.text.SimpleDateFormat.get2DigitYearStart() ()
          Returns the beginning date of the 100-year period 2-digit years are interpreted as being within.
 DateFormatSymbols sample code for java.text.DateFormatSymbols definition code for java.text.DateFormatSymbols getDateFormatSymbols sample code for java.text.SimpleDateFormat.getDateFormatSymbols() definition code for java.text.SimpleDateFormat.getDateFormatSymbols() ()
          Gets a copy of the date and time format symbols of this date format.
 int hashCode sample code for java.text.SimpleDateFormat.hashCode() definition code for java.text.SimpleDateFormat.hashCode() ()
          Returns the hash code value for this SimpleDateFormat object.
 Date sample code for java.util.Date definition code for java.util.Date parse sample code for java.text.SimpleDateFormat.parse(java.lang.String, java.text.ParsePosition) definition code for java.text.SimpleDateFormat.parse(java.lang.String, java.text.ParsePosition) (String sample code for java.lang.String definition code for java.lang.String  text, ParsePosition sample code for java.text.ParsePosition definition code for java.text.ParsePosition  pos)
          Parses text from a string to produce a Date.
 void set2DigitYearStart sample code for java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date) definition code for java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date) (Date sample code for java.util.Date definition code for java.util.Date  startDate)
          Sets the 100-year period 2-digit years will be interpreted as being in to begin on the date the user specifies.
 void setDateFormatSymbols sample code for java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols) definition code for java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols) (DateFormatSymbols sample code for java.text.DateFormatSymbols definition code for java.text.DateFormatSymbols  newFormatSymbols)
          Sets the date and time format symbols of this date format.
 String sample code for java.lang.String definition code for java.lang.String toLocalizedPattern sample code for java.text.SimpleDateFormat.toLocalizedPattern() definition code for java.text.SimpleDateFormat.toLocalizedPattern() ()
          Returns a localized pattern string describing this date format.
 String sample code for java.lang.String definition code for java.lang.String toPattern sample code for java.text.SimpleDateFormat.toPattern() definition code for java.text.SimpleDateFormat.toPattern() ()
          Returns a pattern string describing this date format.
 
Methods inherited from class java.text.DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
format sample code for java.text.DateFormat.format(java.util.Date) definition code for java.text.DateFormat.format(java.util.Date) , format sample code for java.text.DateFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.DateFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) , getAvailableLocales sample code for java.text.DateFormat.getAvailableLocales() definition code for java.text.DateFormat.getAvailableLocales() , getCalendar sample code for java.text.DateFormat.getCalendar() definition code for java.text.DateFormat.getCalendar() , getDateInstance sample code for java.text.DateFormat.getDateInstance() definition code for java.text.DateFormat.getDateInstance() , getDateInstance sample code for java.text.DateFormat.getDateInstance(int) definition code for java.text.DateFormat.getDateInstance(int) , getDateInstance sample code for java.text.DateFormat.getDateInstance(int, java.util.Locale) definition code for java.text.DateFormat.getDateInstance(int, java.util.Locale) , getDateTimeInstance sample code for java.text.DateFormat.getDateTimeInstance() definition code for java.text.DateFormat.getDateTimeInstance() , getDateTimeInstance sample code for java.text.DateFormat.getDateTimeInstance(int, int) definition code for java.text.DateFormat.getDateTimeInstance(int, int) , getDateTimeInstance sample code for java.text.DateFormat.getDateTimeInstance(int, int, java.util.Locale) definition code for java.text.DateFormat.getDateTimeInstance(int, int, java.util.Locale) , getInstance sample code for java.text.DateFormat.getInstance() definition code for java.text.DateFormat.getInstance() , getNumberFormat sample code for java.text.DateFormat.getNumberFormat() definition code for java.text.DateFormat.getNumberFormat() , getTimeInstance sample code for java.text.DateFormat.getTimeInstance() definition code for java.text.DateFormat.getTimeInstance() , getTimeInstance sample code for java.text.DateFormat.getTimeInstance(int) definition code for java.text.DateFormat.getTimeInstance(int) , getTimeInstance sample code for java.text.DateFormat.getTimeInstance(int, java.util.Locale) definition code for java.text.DateFormat.getTimeInstance(int, java.util.Locale) , getTimeZone sample code for java.text.DateFormat.getTimeZone() definition code for java.text.DateFormat.getTimeZone() , isLenient sample code for java.text.DateFormat.isLenient() definition code for java.text.DateFormat.isLenient() , parse sample code for java.text.DateFormat.parse(java.lang.String) definition code for java.text.DateFormat.parse(java.lang.String) , parseObject sample code for java.text.DateFormat.parseObject(java.lang.String, java.text.ParsePosition) definition code for java.text.DateFormat.parseObject(java.lang.String, java.text.ParsePosition) , setCalendar sample code for java.text.DateFormat.setCalendar(java.util.Calendar) definition code for java.text.DateFormat.setCalendar(java.util.Calendar) , setLenient sample code for java.text.DateFormat.setLenient(boolean) definition code for java.text.DateFormat.setLenient(boolean) , setNumberFormat sample code for java.text.DateFormat.setNumberFormat(java.text.NumberFormat) definition code for java.text.DateFormat.setNumberFormat(java.text.NumberFormat) , setTimeZone sample code for java.text.DateFormat.setTimeZone(java.util.TimeZone) definition code for java.text.DateFormat.setTimeZone(java.util.TimeZone)
 
Methods inherited from class java.text.Format sample code for java.text.Format definition code for java.text.Format
format sample code for java.text.Format.format(java.lang.Object) definition code for java.text.Format.format(java.lang.Object) , parseObject sample code for java.text.Format.parseObject(java.lang.String) definition code for java.text.Format.parseObject(java.lang.String)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

SimpleDateFormat sample code for java.text.SimpleDateFormat() definition code for java.text.SimpleDateFormat()

public SimpleDateFormat()
Constructs a SimpleDateFormat using the default pattern and date format symbols for the default locale. Note: This constructor may not support all locales. For full coverage, use the factory methods in the DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat class.


SimpleDateFormat sample code for java.text.SimpleDateFormat(java.lang.String) definition code for java.text.SimpleDateFormat(java.lang.String)

public SimpleDateFormat(String sample code for java.lang.String definition code for java.lang.String  pattern)
Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the default locale. Note: This constructor may not support all locales. For full coverage, use the factory methods in the DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat class.

Parameters:
pattern - the pattern describing the date and time format
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the given pattern is null
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the given pattern is invalid

SimpleDateFormat sample code for java.text.SimpleDateFormat(java.lang.String, java.util.Locale) definition code for java.text.SimpleDateFormat(java.lang.String, java.util.Locale)

public SimpleDateFormat(String sample code for java.lang.String definition code for java.lang.String  pattern,
                        Locale sample code for java.util.Locale definition code for java.util.Locale  locale)
Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the given locale. Note: This constructor may not support all locales. For full coverage, use the factory methods in the DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat class.

Parameters:
pattern - the pattern describing the date and time format
locale - the locale whose date format symbols should be used
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the given pattern is null
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the given pattern is invalid

SimpleDateFormat sample code for java.text.SimpleDateFormat(java.lang.String, java.text.DateFormatSymbols) definition code for java.text.SimpleDateFormat(java.lang.String, java.text.DateFormatSymbols)

public SimpleDateFormat(String sample code for java.lang.String definition code for java.lang.String  pattern,
                        DateFormatSymbols sample code for java.text.DateFormatSymbols definition code for java.text.DateFormatSymbols  formatSymbols)
Constructs a SimpleDateFormat using the given pattern and date format symbols.

Parameters:
pattern - the pattern describing the date and time format
formatSymbols - the date format symbols to be used for formatting
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the given pattern or formatSymbols is null
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the given pattern is invalid
Method Detail

set2DigitYearStart sample code for java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date) definition code for java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date)

public void set2DigitYearStart(Date sample code for java.util.Date definition code for java.util.Date  startDate)
Sets the 100-year period 2-digit years will be interpreted as being in to begin on the date the user specifies.

Parameters:
startDate - During parsing, two digit years will be placed in the range startDate to startDate + 100 years.
Since:
1.2
See Also:
get2DigitYearStart() sample code for java.text.SimpleDateFormat.get2DigitYearStart() definition code for java.text.SimpleDateFormat.get2DigitYearStart()

get2DigitYearStart sample code for java.text.SimpleDateFormat.get2DigitYearStart() definition code for java.text.SimpleDateFormat.get2DigitYearStart()

public Date sample code for java.util.Date definition code for java.util.Date  get2DigitYearStart()
Returns the beginning date of the 100-year period 2-digit years are interpreted as being within.

Returns:
the start of the 100-year period into which two digit years are parsed
Since:
1.2
See Also:
set2DigitYearStart(java.util.Date) sample code for java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date) definition code for java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date)

format sample code for java.text.SimpleDateFormat.format(java.util.Date, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.SimpleDateFormat.format(java.util.Date, java.lang.StringBuffer, java.text.FieldPosition)

public StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  format(Date sample code for java.util.Date definition code for java.util.Date  date,
                           StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo,
                           FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
Formats the given Date into a date/time string and appends the result to the given StringBuffer.

Specified by:
format sample code for java.text.DateFormat.format(java.util.Date, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.DateFormat.format(java.util.Date, java.lang.StringBuffer, java.text.FieldPosition) in class DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
Parameters:
date - the date-time value to be formatted into a date-time string.
toAppendTo - where the new date-time text is to be appended.
pos - the formatting position. On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
the formatted date-time string.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the given date is null

formatToCharacterIterator sample code for java.text.SimpleDateFormat.formatToCharacterIterator(java.lang.Object) definition code for java.text.SimpleDateFormat.formatToCharacterIterator(java.lang.Object)

public AttributedCharacterIterator sample code for java.text.AttributedCharacterIterator definition code for java.text.AttributedCharacterIterator  formatToCharacterIterator(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Formats an Object producing an AttributedCharacterIterator. You can use the returned AttributedCharacterIterator to build the resulting String, as well as to determine information about the resulting String.

Each attribute key of the AttributedCharacterIterator will be of type DateFormat.Field, with the corresponding attribute value being the same as the attribute key.

Overrides:
formatToCharacterIterator sample code for java.text.Format.formatToCharacterIterator(java.lang.Object) definition code for java.text.Format.formatToCharacterIterator(java.lang.Object) in class Format sample code for java.text.Format definition code for java.text.Format
Parameters:
obj - The object to format
Returns:
AttributedCharacterIterator describing the formatted value.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if obj is null.
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the Format cannot format the given object, or if the Format's pattern string is invalid.
Since:
1.4

parse sample code for java.text.SimpleDateFormat.parse(java.lang.String, java.text.ParsePosition) definition code for java.text.SimpleDateFormat.parse(java.lang.String, java.text.ParsePosition)

public Date sample code for java.util.Date definition code for java.util.Date  parse(String sample code for java.lang.String definition code for java.lang.String  text,
                  ParsePosition sample code for java.text.ParsePosition definition code for java.text.ParsePosition  pos)
Parses text from a string to produce a Date.

The method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed date is returned. The updated pos can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of pos is not changed, the error index of pos is set to the index of the character where the error occurred, and null is returned.

Specified by:
parse sample code for java.text.DateFormat.parse(java.lang.String, java.text.ParsePosition) definition code for java.text.DateFormat.parse(java.lang.String, java.text.ParsePosition) in class DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
Parameters:
text - A String, part of which should be parsed.
pos - A ParsePosition object with index and error index information as described above.
Returns:
A Date parsed from the string. In case of error, returns null.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if text or pos is null.
See Also:
DateFormat.setLenient(boolean) sample code for java.text.DateFormat.setLenient(boolean) definition code for java.text.DateFormat.setLenient(boolean)

toPattern sample code for java.text.SimpleDateFormat.toPattern() definition code for java.text.SimpleDateFormat.toPattern()

public String sample code for java.lang.String definition code for java.lang.String  toPattern()
Returns a pattern string describing this date format.

Returns:
a pattern string describing this date format.

toLocalizedPattern sample code for java.text.SimpleDateFormat.toLocalizedPattern() definition code for java.text.SimpleDateFormat.toLocalizedPattern()

public String sample code for java.lang.String definition code for java.lang.String  toLocalizedPattern()
Returns a localized pattern string describing this date format.

Returns:
a localized pattern string describing this date format.

applyPattern sample code for java.text.SimpleDateFormat.applyPattern(java.lang.String) definition code for java.text.SimpleDateFormat.applyPattern(java.lang.String)

public void applyPattern(String sample code for java.lang.String definition code for java.lang.String  pattern)
Applies the given pattern string to this date format.

Parameters:
pattern - the new date and time pattern for this date format
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the given pattern is null
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the given pattern is invalid

applyLocalizedPattern sample code for java.text.SimpleDateFormat.applyLocalizedPattern(java.lang.String) definition code for java.text.SimpleDateFormat.applyLocalizedPattern(java.lang.String)

public void applyLocalizedPattern(String sample code for java.lang.String definition code for java.lang.String  pattern)
Applies the given localized pattern string to this date format.

Parameters:
pattern - a String to be mapped to the new date and time format pattern for this format
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the given pattern is null
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the given pattern is invalid

getDateFormatSymbols sample code for java.text.SimpleDateFormat.getDateFormatSymbols() definition code for java.text.SimpleDateFormat.getDateFormatSymbols()

public DateFormatSymbols sample code for java.text.DateFormatSymbols definition code for java.text.DateFormatSymbols  getDateFormatSymbols()
Gets a copy of the date and time format symbols of this date format.

Returns:
the date and time format symbols of this date format
See Also:
setDateFormatSymbols(java.text.DateFormatSymbols) sample code for java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols) definition code for java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols)

setDateFormatSymbols sample code for java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols) definition code for java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols)

public void setDateFormatSymbols(DateFormatSymbols sample code for java.text.DateFormatSymbols definition code for java.text.DateFormatSymbols  newFormatSymbols)
Sets the date and time format symbols of this date format.

Parameters:
newFormatSymbols - the new date and time format symbols
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the given newFormatSymbols is null
See Also:
getDateFormatSymbols() sample code for java.text.SimpleDateFormat.getDateFormatSymbols() definition code for java.text.SimpleDateFormat.getDateFormatSymbols()

clone sample code for java.text.SimpleDateFormat.clone() definition code for java.text.SimpleDateFormat.clone()

public Object sample code for java.lang.Object definition code for java.lang.Object  clone()
Creates a copy of this SimpleDateFormat. This also clones the format's date format symbols.

Overrides:
clone sample code for java.text.DateFormat.clone() definition code for java.text.DateFormat.clone() in class DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
Returns:
a clone of this SimpleDateFormat
See Also:
Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

hashCode sample code for java.text.SimpleDateFormat.hashCode() definition code for java.text.SimpleDateFormat.hashCode()

public int hashCode()
Returns the hash code value for this SimpleDateFormat object.

Overrides:
hashCode sample code for java.text.DateFormat.hashCode() definition code for java.text.DateFormat.hashCode() in class DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
Returns:
the hash code value for this SimpleDateFormat object.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

equals sample code for java.text.SimpleDateFormat.equals(java.lang.Object) definition code for java.text.SimpleDateFormat.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Compares the given object with this SimpleDateFormat for equality.

Overrides:
equals sample code for java.text.DateFormat.equals(java.lang.Object) definition code for java.text.DateFormat.equals(java.lang.Object) in class DateFormat sample code for java.text.DateFormat definition code for java.text.DateFormat
Parameters:
obj - the reference object with which to compare.
Returns:
true if the given object is equal to this SimpleDateFormat
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable