Class DateFormatUtils
Date and time formatting utilities and constants.
Formatting is performed using the thread-safe
FastDateFormat class.
Note that the JDK has a bug wherein calling Calendar.get(int) will override any previously called Calendar.clear() calls. See LANG-755.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FastDateFormatISO 8601 formatter for date without time zone.static final FastDateFormatISO 8601 formatter for date-time without time zone.static final FastDateFormatISO 8601 formatter for date-time with time zone.static final FastDateFormatISO 8601 formatter for time without time zone.static final FastDateFormatISO 8601 formatter for time with time zone.static final FastDateFormatDeprecated.- as of 4.0, ISO_DATE_FORMAT will be replaced by ISO_8601_EXTENDED_DATE_FORMAT.static final FastDateFormatDeprecated.- as of 4.0, ISO_DATE_TIME_ZONE_FORMAT will be removed.static final FastDateFormatDeprecated.- as of 4.0, ISO_DATETIME_FORMAT will be replaced by ISO_8601_EXTENDED_DATETIME_FORMAT.static final FastDateFormatDeprecated.- as of 4.0, ISO_DATETIME_TIME_ZONE_FORMAT will be replaced by ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT.static final FastDateFormatDeprecated.- as of 4.0, ISO_TIME_FORMAT will be removed.static final FastDateFormatDeprecated.- as of 4.0, ISO_TIME_NO_T_FORMAT will be replaced by ISO_8601_EXTENDED_TIME_FORMAT.static final FastDateFormatDeprecated.- as of 4.0, ISO_TIME_NO_T_TIME_ZONE_FORMAT will be replaced by ISO_8601_EXTENDED_TIME_TIME_ZONE_FORMAT.static final FastDateFormatDeprecated.- as of 4.0, ISO_TIME_TIME_ZONE_FORMAT will be removed.static final FastDateFormatSMTP (and probably other) date headers.private static final TimeZoneThe UTC time zone (often referred to as GMT). -
Constructor Summary
ConstructorsConstructorDescriptionDateFormatUtils instances should NOT be constructed in standard programming. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormats a date/time into a specific pattern.static StringFormats a date/time into a specific pattern in a locale.static StringFormats a date/time into a specific pattern in a time zone.static StringFormats a date/time into a specific pattern in a time zone and locale.static StringFormats a calendar into a specific pattern.static StringFormats a calendar into a specific pattern in a locale.static StringFormats a calendar into a specific pattern in a time zone.static StringFormats a calendar into a specific pattern in a time zone and locale.static StringFormats a date/time into a specific pattern.static StringFormats a date/time into a specific pattern in a locale.static StringFormats a date/time into a specific pattern in a time zone.static StringFormats a date/time into a specific pattern in a time zone and locale.static StringFormats a date/time into a specific pattern using the UTC time zone.static StringFormats a date/time into a specific pattern using the UTC time zone.static StringFormats a date/time into a specific pattern using the UTC time zone.static StringFormats a date/time into a specific pattern using the UTC time zone.
-
Field Details
-
UTC_TIME_ZONE
The UTC time zone (often referred to as GMT). This is private as it is mutable. -
ISO_8601_EXTENDED_DATETIME_FORMAT
ISO 8601 formatter for date-time without time zone.The format used is
yyyy-MM-dd'T'HH:mm:ss. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class.- Since:
- 3.5
-
ISO_DATETIME_FORMAT
Deprecated.- as of 4.0, ISO_DATETIME_FORMAT will be replaced by ISO_8601_EXTENDED_DATETIME_FORMAT. -
ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT
ISO 8601 formatter for date-time with time zone.The format used is
yyyy-MM-dd'T'HH:mm:ssZZ. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class.- Since:
- 3.5
-
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_8601_EXTENDED_DATE_FORMAT
ISO 8601 formatter for date without time zone.The format used is
yyyy-MM-dd. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class.- Since:
- 3.5
-
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
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
yyyy-MM-ddZZ. This pattern does not comply with the formal ISO 8601 specification as the standard does not allow a time zone without a time. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. -
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
'T'HH:mm:ss. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. -
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
'T'HH:mm:ssZZ. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. -
ISO_8601_EXTENDED_TIME_FORMAT
ISO 8601 formatter for time without time zone.The format used is
HH:mm:ss. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class.- Since:
- 3.5
-
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_8601_EXTENDED_TIME_TIME_ZONE_FORMAT
ISO 8601 formatter for time with time zone.The format used is
HH:mm:ssZZ. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class.- Since:
- 3.5
-
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. -
SMTP_DATETIME_FORMAT
SMTP (and probably other) date headers.The format used is
EEE, dd MMM yyyy HH:mm:ss Zin US locale. This format uses the default TimeZone in effect at the time of loading DateFormatUtils class.
-
-
Constructor Details
-
DateFormatUtils
public DateFormatUtils()DateFormatUtils instances should NOT be constructed in standard programming.
This constructor is public to permit tools that require a JavaBean instance to operate.
-
-
Method Details
-
formatUTC
Formats a date/time into a specific pattern using the UTC time zone.
- Parameters:
millis- the date to format expressed in millisecondspattern- the pattern to use to format the date, not null- Returns:
- the formatted date
-
formatUTC
Formats a date/time into a specific pattern using the UTC time zone.
- Parameters:
date- the date to format, not nullpattern- the pattern to use to format the date, not null- Returns:
- the formatted date
-
formatUTC
Formats a date/time into a specific pattern using the UTC time zone.
- Parameters:
millis- the date to format expressed in millisecondspattern- the pattern to use to format the date, not nulllocale- the locale to use, may benull- Returns:
- the formatted date
-
formatUTC
Formats a date/time into a specific pattern using the UTC time zone.
- Parameters:
date- the date to format, not nullpattern- the pattern to use to format the date, not nulllocale- the locale to use, may benull- Returns:
- the formatted date
-
format
Formats a date/time into a specific pattern.
- Parameters:
millis- the date to format expressed in millisecondspattern- the pattern to use to format the date, not null- Returns:
- the formatted date
-
format
Formats a date/time into a specific pattern.
- Parameters:
date- the date to format, not nullpattern- the pattern to use to format the date, not null- Returns:
- the formatted date
-
format
Formats a calendar into a specific pattern.
- Parameters:
calendar- the calendar to format, not nullpattern- the pattern to use to format the calendar, not null- Returns:
- the formatted calendar
- Since:
- 2.4
- See Also:
-
format
Formats a date/time into a specific pattern in a time zone.
- Parameters:
millis- the time expressed in millisecondspattern- the pattern to use to format the date, not nulltimeZone- the time zone to use, may benull- Returns:
- the formatted date
-
format
Formats a date/time into a specific pattern in a time zone.
- Parameters:
date- the date to format, not nullpattern- the pattern to use to format the date, not nulltimeZone- the time zone to use, may benull- Returns:
- the formatted date
-
format
Formats a calendar into a specific pattern in a time zone.
- Parameters:
calendar- the calendar to format, not nullpattern- the pattern to use to format the calendar, not nulltimeZone- the time zone to use, may benull- Returns:
- the formatted calendar
- Since:
- 2.4
- See Also:
-
format
Formats a date/time into a specific pattern in a locale.
- Parameters:
millis- the date to format expressed in millisecondspattern- the pattern to use to format the date, not nulllocale- the locale to use, may benull- Returns:
- the formatted date
-
format
Formats a date/time into a specific pattern in a locale.
- Parameters:
date- the date to format, not nullpattern- the pattern to use to format the date, not nulllocale- the locale to use, may benull- Returns:
- the formatted date
-
format
Formats a calendar into a specific pattern in a locale.
- Parameters:
calendar- the calendar to format, not nullpattern- the pattern to use to format the calendar, not nulllocale- the locale to use, may benull- Returns:
- the formatted calendar
- Since:
- 2.4
- See Also:
-
format
Formats a date/time into a specific pattern in a time zone and locale.
- Parameters:
millis- the date to format expressed in millisecondspattern- the pattern to use to format the date, not nulltimeZone- the time zone to use, may benulllocale- the locale to use, may benull- Returns:
- the formatted date
-
format
Formats a date/time into a specific pattern in a time zone and locale.
- Parameters:
date- the date to format, not nullpattern- the pattern to use to format the date, not null, not nulltimeZone- the time zone to use, may benulllocale- the locale to use, may benull- Returns:
- the formatted date
-
format
Formats a calendar into a specific pattern in a time zone and locale.
- Parameters:
calendar- the calendar to format, not nullpattern- the pattern to use to format the calendar, not nulltimeZone- the time zone to use, may benulllocale- the locale to use, may benull- Returns:
- the formatted calendar
- Since:
- 2.4
- See Also:
-