Name
SimpleDateFormat
Synopsis
This is the concrete
Format subclass used by
DateFormat to handle the formatting and parsing of
dates. Most applications should not use this class directly; instead,
they should obtain a localized DateFormat object
by calling one of the static methods of
DateFormat.
SimpleDateFormat formats dates and times according
to a pattern, which specifies the positions of the various fields of
the date, and a DateFormatSymbols object, which
specifies important auxiliary data, such as the names of months.
Applications that require highly customized date or time formatting
can create a custom SimpleDateFormat object by
specifying the desired pattern. This creates a
SimpleDateFormat object that uses the
DateFormatSymbols object for the default locale.
You may also specify an locale explicitly, to use the
DateFormatSymbols object for that locale. You can
even provide an explicit DateFormatSymbols object
of your own if you need to format dates and times for an unsupported
locale.
You can use the applyPattern(
) method of a SimpleDateFormat to change
the formatting pattern used by the object. The syntax of this pattern
is described in the following table. Any characters in the format
string that do not appear in this table appear literally in the
formatted date.
|
Field |
Full form |
Short form |
|---|---|---|
|
Year |
|
|
|
Month |
|
|
|
Day of week |
|
|
|
Day of month |
|
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access