Package org.sqlite.date
Class DateFormatUtils
- java.lang.Object
-
- org.sqlite.date.DateFormatUtils
-
public class DateFormatUtils extends Object
Date and time formatting utilities and constants.Formatting is performed using the thread-safe org.apache.commons.lang3.time.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
- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description static FastDateFormat
ISO_DATE_FORMAT
ISO 8601 formatter for date without time zone.static FastDateFormat
ISO_DATE_TIME_ZONE_FORMAT
ISO 8601-like formatter for date with time zone.static FastDateFormat
ISO_DATETIME_FORMAT
ISO 8601 formatter for date-time without time zone.static FastDateFormat
ISO_DATETIME_TIME_ZONE_FORMAT
ISO 8601 formatter for date-time with time zone.static FastDateFormat
ISO_TIME_FORMAT
ISO 8601 formatter for time without time zone.static FastDateFormat
ISO_TIME_NO_T_FORMAT
ISO 8601-like formatter for time without time zone.static FastDateFormat
ISO_TIME_NO_T_TIME_ZONE_FORMAT
ISO 8601-like formatter for time with time zone.static FastDateFormat
ISO_TIME_TIME_ZONE_FORMAT
ISO 8601 formatter for time with time zone.static FastDateFormat
SMTP_DATETIME_FORMAT
SMTP (and probably other) date headers.
-
Constructor Summary
Constructors Constructor Description DateFormatUtils()
DateFormatUtils instances should NOT be constructed in standard programming.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
format(long millis, String pattern)
Formats a date/time into a specific pattern.static String
format(long millis, String pattern, Locale locale)
Formats a date/time into a specific pattern in a locale.static String
format(long millis, String pattern, TimeZone timeZone)
Formats a date/time into a specific pattern in a time zone.static String
format(long millis, String pattern, TimeZone timeZone, Locale locale)
Formats a date/time into a specific pattern in a time zone and locale.static String
format(Calendar calendar, String pattern)
Formats a calendar into a specific pattern.static String
format(Calendar calendar, String pattern, Locale locale)
Formats a calendar into a specific pattern in a locale.static String
format(Calendar calendar, String pattern, TimeZone timeZone)
Formats a calendar into a specific pattern in a time zone.static String
format(Calendar calendar, String pattern, TimeZone timeZone, Locale locale)
Formats a calendar into a specific pattern in a time zone and locale.static String
format(Date date, String pattern)
Formats a date/time into a specific pattern.static String
format(Date date, String pattern, Locale locale)
Formats a date/time into a specific pattern in a locale.static String
format(Date date, String pattern, TimeZone timeZone)
Formats a date/time into a specific pattern in a time zone.static String
format(Date date, String pattern, TimeZone timeZone, Locale locale)
Formats a date/time into a specific pattern in a time zone and locale.static String
formatUTC(long millis, String pattern)
Formats a date/time into a specific pattern using the UTC time zone.static String
formatUTC(long millis, String pattern, Locale locale)
Formats a date/time into a specific pattern using the UTC time zone.static String
formatUTC(Date date, String pattern)
Formats a date/time into a specific pattern using the UTC time zone.static String
formatUTC(Date date, String pattern, Locale locale)
Formats a date/time into a specific pattern using the UTC time zone.
-
-
-
Field Detail
-
ISO_DATETIME_FORMAT
public static final FastDateFormat ISO_DATETIME_FORMAT
ISO 8601 formatter for date-time without time zone. The format used isyyyy-MM-dd'T'HH:mm:ss
.
-
ISO_DATETIME_TIME_ZONE_FORMAT
public static final FastDateFormat ISO_DATETIME_TIME_ZONE_FORMAT
ISO 8601 formatter for date-time with time zone. The format used isyyyy-MM-dd'T'HH:mm:ssZZ
.
-
ISO_DATE_FORMAT
public static final FastDateFormat ISO_DATE_FORMAT
ISO 8601 formatter for date without time zone. The format used isyyyy-MM-dd
.
-
ISO_DATE_TIME_ZONE_FORMAT
public static final FastDateFormat ISO_DATE_TIME_ZONE_FORMAT
ISO 8601-like formatter for date with time zone. The format used isyyyy-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.
-
ISO_TIME_FORMAT
public static final FastDateFormat ISO_TIME_FORMAT
ISO 8601 formatter for time without time zone. The format used is'T'HH:mm:ss
.
-
ISO_TIME_TIME_ZONE_FORMAT
public static final FastDateFormat ISO_TIME_TIME_ZONE_FORMAT
ISO 8601 formatter for time with time zone. The format used is'T'HH:mm:ssZZ
.
-
ISO_TIME_NO_T_FORMAT
public static final FastDateFormat ISO_TIME_NO_T_FORMAT
ISO 8601-like formatter for time without time zone. The format used isHH:mm:ss
. This pattern does not comply with the formal ISO 8601 specification as the standard requires the 'T' prefix for times.
-
ISO_TIME_NO_T_TIME_ZONE_FORMAT
public static final FastDateFormat ISO_TIME_NO_T_TIME_ZONE_FORMAT
ISO 8601-like formatter for time with time zone. The format used isHH:mm:ssZZ
. This pattern does not comply with the formal ISO 8601 specification as the standard requires the 'T' prefix for times.
-
SMTP_DATETIME_FORMAT
public static final FastDateFormat SMTP_DATETIME_FORMAT
SMTP (and probably other) date headers. The format used isEEE, dd MMM yyyy HH:mm:ss Z
in US locale.
-
-
Method Detail
-
formatUTC
public static String formatUTC(long millis, String pattern)
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
public static String formatUTC(Date date, String pattern)
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
public static String formatUTC(long millis, String pattern, Locale locale)
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
public static String formatUTC(Date date, String pattern, Locale locale)
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
public static String format(long millis, String pattern)
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
public static String format(Date date, String pattern)
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
public static String format(Calendar calendar, String pattern)
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:
FastDateFormat.format(Calendar)
-
format
public static String format(long millis, String pattern, TimeZone timeZone)
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
public static String format(Date date, String pattern, TimeZone timeZone)
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
public static String format(Calendar calendar, String pattern, TimeZone timeZone)
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:
FastDateFormat.format(Calendar)
-
format
public static String format(long millis, String pattern, Locale locale)
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
public static String format(Date date, String pattern, Locale locale)
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
public static String format(Calendar calendar, String pattern, Locale locale)
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:
FastDateFormat.format(Calendar)
-
format
public static String format(long millis, String pattern, TimeZone timeZone, Locale locale)
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 benull
locale
- the locale to use, may benull
- Returns:
- the formatted date
-
format
public static String format(Date date, String pattern, TimeZone timeZone, Locale locale)
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 benull
locale
- the locale to use, may benull
- Returns:
- the formatted date
-
format
public static String format(Calendar calendar, String pattern, TimeZone timeZone, Locale locale)
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 benull
locale
- the locale to use, may benull
- Returns:
- the formatted calendar
- Since:
- 2.4
- See Also:
FastDateFormat.format(Calendar)
-
-