Formatting is performed using the thread-safe
org. class.
Note that the JDK has a bug wherein calling Calendar.get(int) will override any previously called Calendar.clear() calls. See LANG-755.
Note that when using capital YYYY instead of lowercase yyyy, the formatter
will assume current year as week year is not supported. See java.
Week Year section for an explanation on the difference between calendar and week years.
| Modifier and Type | Field and Description |
|---|---|
| public static final FastDateFormat | ISO_8601_EXTENDED_DATE_FORMAT
ISO 8601 formatter for date without time zone. |
| public static final FastDateFormat | ISO_8601_EXTENDED_DATETIME_FORMAT
ISO 8601 formatter for date-time without time zone. |
| public static final FastDateFormat | ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT
ISO 8601 formatter for date-time with time zone. |
| public static final FastDateFormat | ISO_8601_EXTENDED_TIME_FORMAT
ISO 8601 formatter for time without time zone. |
| public static final FastDateFormat | ISO_8601_EXTENDED_TIME_TIME_ZONE_FORMAT
ISO 8601 formatter for time with time zone. |
| public static final FastDateFormat | ISO_DATE_FORMAT
Deprecated
- as of 4.0, ISO_DATE_FORMAT will be replaced by ISO_8601_EXTENDED_DATE_FORMAT.
|
| public static final FastDateFormat | ISO_DATE_TIME_ZONE_FORMAT
Deprecated
- as of 4.0, ISO_DATE_TIME_ZONE_FORMAT will be removed.
ISO 8601-like formatter for date with time zone.
|
| public static final FastDateFormat | ISO_DATETIME_FORMAT
Deprecated
- as of 4.0, ISO_DATETIME_FORMAT will be replaced by ISO_8601_EXTENDED_DATETIME_FORMAT.
|
| public static final FastDateFormat | ISO_DATETIME_TIME_ZONE_FORMAT
Deprecated
- as of 4.0, ISO_DATETIME_TIME_ZONE_FORMAT will be replaced by ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT.
|
| public static final FastDateFormat | ISO_TIME_FORMAT
Deprecated
- as of 4.0, ISO_TIME_FORMAT will be removed.
Non-compliant formatter for time without time zone (ISO 8601 does not
prefix 'T' for standalone time value).
|
| public static final FastDateFormat | ISO_TIME_NO_T_FORMAT
Deprecated
- as of 4.0, ISO_TIME_NO_T_FORMAT will be replaced by ISO_8601_EXTENDED_TIME_FORMAT.
|
| public static final FastDateFormat | ISO_TIME_NO_T_TIME_ZONE_FORMAT
Deprecated
- as of 4.0, ISO_TIME_NO_T_TIME_ZONE_FORMAT will be replaced by ISO_8601_EXTENDED_TIME_TIME_ZONE_FORMAT.
|
| public static final FastDateFormat | ISO_TIME_TIME_ZONE_FORMAT
Deprecated
- as of 4.0, ISO_TIME_TIME_ZONE_FORMAT will be removed.
Non-compliant formatter for time with time zone (ISO 8601 does not
prefix 'T' for standalone time value).
|
| public static final FastDateFormat | SMTP_DATETIME_FORMAT
SMTP (and probably other) date headers. |
| private static final TimeZone | UTC_TIME_ZONE
The UTC time zone (often referred to as GMT). |
| Access | Constructor and Description |
|---|---|
| public | DateFormatUtils()
Deprecated
TODO Make private in 4.0.
DateFormatUtils instances should NOT be constructed in standard programming. |
| Modifier and Type | Method and Description |
|---|---|
| public static String | |
| public static String | |
| public static String | |
| public static String | Returns: the formatted calendar.the calendar to format, not null. calendar, final String the pattern to use to format the calendar, not null. pattern, final TimeZone the time zone to use, may be timeZone, final Locale null.the locale to use, may be locale)null.Formats a calendar into a specific pattern in a time zone and locale. |
| public static String | |
| public static String | |
| public static String | |
| public static String | Returns: the formatted date.the date to format, not null. date, final String the pattern to use to format the date, not null, not null. pattern, final TimeZone the time zone to use, may be timeZone, final Locale null.the locale to use, may be locale)null.Formats a date/time into a specific pattern in a time zone and locale. |
| public static String | |
| public static String | |
| public static String | |
| public static String | Returns: the formatted date.the date to format expressed in milliseconds. millis, final String the pattern to use to format the date, not null. pattern, final TimeZone the time zone to use, may be timeZone, final Locale null.the locale to use, may be locale)null.Formats a date/time into a specific pattern in a time zone and locale. |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| private static TimeZone |
| ISO_8601_EXTENDED_DATE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_8601_EXTENDED_DATE_FORMAT ISO 8601 formatter for date without time zone.
The format used is
| |
| ISO_8601_EXTENDED_DATETIME_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_8601_EXTENDED_DATETIME_FORMAT ISO 8601 formatter for date-time without time zone.
The format used is
| |
| ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT ISO 8601 formatter for date-time with time zone.
The format used is
| |
| ISO_8601_EXTENDED_TIME_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_8601_EXTENDED_TIME_FORMAT ISO 8601 formatter for time without time zone.
The format used is
| |
| ISO_8601_EXTENDED_TIME_TIME_ZONE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_8601_EXTENDED_TIME_TIME_ZONE_FORMAT ISO 8601 formatter for time with time zone.
The format used is
| |
| ISO_DATE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_DATE_FORMAT
Deprecated - as of 4.0, ISO_DATE_FORMAT will be replaced by ISO_8601_EXTENDED_DATE_FORMAT. | |
| ISO_DATE_TIME_ZONE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_DATE_TIME_ZONE_FORMAT
Deprecated - as of 4.0, ISO_DATE_TIME_ZONE_FORMAT will be removed. ISO 8601-like formatter for date with time zone.
The format used is | |
| ISO_DATETIME_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_DATETIME_FORMAT
Deprecated - as of 4.0, ISO_DATETIME_FORMAT will be replaced by ISO_8601_EXTENDED_DATETIME_FORMAT. | |
| ISO_DATETIME_TIME_ZONE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_DATETIME_TIME_ZONE_FORMAT
Deprecated - as of 4.0, ISO_DATETIME_TIME_ZONE_FORMAT will be replaced by ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT. | |
| ISO_TIME_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_TIME_FORMAT
Deprecated - as of 4.0, ISO_TIME_FORMAT will be removed. Non-compliant formatter for time without time zone (ISO 8601 does not prefix 'T' for standalone time value).
The format used is | |
| ISO_TIME_NO_T_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_TIME_NO_T_FORMAT
Deprecated - as of 4.0, ISO_TIME_NO_T_FORMAT will be replaced by ISO_8601_EXTENDED_TIME_FORMAT. | |
| ISO_TIME_NO_T_TIME_ZONE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_TIME_NO_T_TIME_ZONE_FORMAT
Deprecated - as of 4.0, ISO_TIME_NO_T_TIME_ZONE_FORMAT will be replaced by ISO_8601_EXTENDED_TIME_TIME_ZONE_FORMAT. | |
| ISO_TIME_TIME_ZONE_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat ISO_TIME_TIME_ZONE_FORMAT
Deprecated - as of 4.0, ISO_TIME_TIME_ZONE_FORMAT will be removed. Non-compliant formatter for time with time zone (ISO 8601 does not prefix 'T' for standalone time value).
The format used is | |
| SMTP_DATETIME_FORMAT | back to summary |
|---|---|
| public static final FastDateFormat SMTP_DATETIME_FORMAT SMTP (and probably other) date headers.
The format used is | |
| UTC_TIME_ZONE | back to summary |
|---|---|
| private static final TimeZone UTC_TIME_ZONE The UTC time zone (often referred to as GMT). This is private as it is mutable. | |
| DateFormatUtils | back to summary |
|---|---|
| public DateFormatUtils()
Deprecated TODO Make private in 4.0. DateFormatUtils instances should NOT be constructed in standard programming. This constructor is public to permit tools that require a JavaBean instance to operate.
| |
| format | back to summary |
|---|---|
| public static String format(final Calendar calendar, final String pattern) Formats a calendar into a specific pattern. The TimeZone from the calendar will be used for formatting.
| |
| format | back to summary |
|---|---|
| public static String format(final Calendar calendar, final String pattern, final Locale locale) Formats a calendar into a specific pattern in a locale. The TimeZone from the calendar will be used for formatting.
| |
| format | back to summary |
|---|---|
| public static String format(final Calendar calendar, final String pattern, final TimeZone timeZone) Formats a calendar into a specific pattern in a time zone.
| |
| format | back to summary |
|---|---|
| public static String format(final Calendar calendar, final String pattern, final TimeZone timeZone, final Locale locale) Formats a calendar into a specific pattern in a time zone and locale.
| |
| format | back to summary |
|---|---|
| public static String format(final Date date, final String pattern) Formats a date/time into a specific pattern. | |
| format | back to summary |
|---|---|
| public static String format(final Date date, final String pattern, final Locale locale) Formats a date/time into a specific pattern in a locale. | |
| format | back to summary |
|---|---|
| public static String format(final Date date, final String pattern, final TimeZone timeZone) Formats a date/time into a specific pattern in a time zone. | |
| format | back to summary |
|---|---|
| public static String format(final Date date, final String pattern, final TimeZone timeZone, final Locale locale) Formats a date/time into a specific pattern in a time zone and locale. | |
| format | back to summary |
|---|---|
| public static String format(final long millis, final String pattern) Formats a date/time into a specific pattern. | |
| format | back to summary |
|---|---|
| public static String format(final long millis, final String pattern, final Locale locale) Formats a date/time into a specific pattern in a locale. | |
| format | back to summary |
|---|---|
| public static String format(final long millis, final String pattern, final TimeZone timeZone) Formats a date/time into a specific pattern in a time zone. | |
| format | back to summary |
|---|---|
| public static String format(final long millis, final String pattern, final TimeZone timeZone, final Locale locale) Formats a date/time into a specific pattern in a time zone and locale. | |
| formatUTC | back to summary |
|---|---|
| public static String formatUTC(final Date date, final String pattern) Formats a date/time into a specific pattern using the UTC time zone. | |
| formatUTC | back to summary |
|---|---|
| public static String formatUTC(final Date date, final String pattern, final Locale locale) Formats a date/time into a specific pattern using the UTC time zone. | |
| formatUTC | back to summary |
|---|---|
| public static String formatUTC(final long millis, final String pattern) Formats a date/time into a specific pattern using the UTC time zone. | |
| formatUTC | back to summary |
|---|---|
| public static String formatUTC(final long millis, final String pattern, final Locale locale) Formats a date/time into a specific pattern using the UTC time zone. | |
| getTimeZone | back to summary |
|---|---|
| private static TimeZone getTimeZone(final Calendar calendar) | |