public final class IlvDateFormatFactory extends Object
IlvDateFormatFactory
class provides static factory methods that can be
used to create date format instances. The method signatures are consistent with those
provided by the standard DateFormat
class and the date formatters returned
are compatible. However, using the methods of this class provides several advantages
over using the standard DateFormat
:
IlvDateFormatFactory
returns instances of IlvDateFormat
,
instead of instances of SimpleDateFormat
. It automatically
uses an ICU SimpleDateFormat
instead of a
java.text.SimpleDateFormat
if appropriate. Also, if the
FastDateFormat
class from the
Jakarta Commons Lang package
is available on the classpath, IlvDateFormat
automatically takes
advantage of this to provide much faster formatted output.
IlvDateFormatFactory
implements caching techniques to provide a
significant speed improvement when creating date format instances.
IlvDateFormat
Modifier and Type | Method and Description |
---|---|
static DateFormat |
getDateInstance()
Returns a date formatter with the default formatting style in the current locale.
|
static DateFormat |
getDateInstance(int dateStyle)
Returns a date formatter with the given
DateFormat style in the current
locale. |
static DateFormat |
getDateInstance(int dateStyle,
com.ibm.icu.util.ULocale locale)
Returns a date formatter with the given
DateFormat style
for the given locale. |
static DateFormat |
getDateTimeInstance()
Returns a date/time formatter with the default formatting style in the current
locale and default timezone.
|
static DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle)
Returns a date/time formatter with the given date and time
DateFormat styles in the current locale and default timezone. |
static DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle,
com.ibm.icu.util.ULocale locale)
Returns a date/time formatter with the given date and time
DateFormat styles for the given locale, in the default timezone. |
static DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle,
com.ibm.icu.util.ULocale locale,
TimeZone timeZone)
Returns a date/time formatter with the given date and time
DateFormat styles for the given locale and timezone. |
static DateFormat |
getInstance()
Returns a default date/time formatter that uses the
DateFormat.SHORT style
for both the date and the time in the current locale and default timezone. |
static DateFormat |
getInstance(String pattern)
Returns a date/time formatter instance using the specified pattern in the
current locale and default timezone.
|
static DateFormat |
getInstance(String pattern,
com.ibm.icu.util.ULocale locale,
TimeZone timeZone)
Returns a date/time formatter instance using the specified pattern for the
given locale and timezone.
|
static DateFormat |
getInstance(com.ibm.icu.util.ULocale locale)
Returns a default date/time formatter that uses the
DateFormat.SHORT style
for both the date and the time in the given locale and default timezone. |
static DateFormat |
getTimeInstance()
Returns a time formatter with the default formatting style in the current
locale and default timezone.
|
static DateFormat |
getTimeInstance(int timeStyle)
Returns a time formatter with the given time
DateFormat style in the current locale and default timezone. |
static DateFormat |
getTimeInstance(int timeStyle,
com.ibm.icu.util.ULocale locale)
Returns a time formatter with the given time
DateFormat style for the given locale, in the default timezone. |
static DateFormat |
getTimeInstance(int timeStyle,
com.ibm.icu.util.ULocale locale,
TimeZone timeZone)
Returns a time formatter with the given time
DateFormat style for the given locale and timezone. |
public static DateFormat getInstance()
DateFormat.SHORT
style
for both the date and the time in the current locale and default timezone.public static DateFormat getInstance(com.ibm.icu.util.ULocale locale)
DateFormat.SHORT
style
for both the date and the time in the given locale and default timezone.public static DateFormat getInstance(String pattern)
pattern
- A SimpleDateFormat
compatible pattern.IllegalArgumentException
- if the pattern is invalid.public static DateFormat getInstance(String pattern, com.ibm.icu.util.ULocale locale, TimeZone timeZone)
pattern
- A SimpleDateFormat
compatible pattern.locale
- The locale or null
for the current locale.timeZone
- The timezone or null
for the default timezone.IllegalArgumentException
- if the pattern is invalid.public static DateFormat getDateInstance()
public static DateFormat getDateInstance(int dateStyle)
DateFormat
style in the current
locale.dateStyle
- The DateFormat
style. For example, DateFormat.SHORT
for "M/d/yy" in the US locale.public static DateFormat getDateInstance(int dateStyle, com.ibm.icu.util.ULocale locale)
DateFormat
style
for the given locale.dateStyle
- The DateFormat
style. For example,
DateFormat.SHORT
for "M/d/yy" in the US locale.locale
- The locale or null
for the current locale.public static DateFormat getTimeInstance()
public static DateFormat getTimeInstance(int timeStyle)
DateFormat
style in the current locale and default timezone.timeStyle
- The time DateFormat
style. For example,
DateFormat.SHORT
for "h:mm a" in the US locale.public static DateFormat getTimeInstance(int timeStyle, com.ibm.icu.util.ULocale locale)
DateFormat
style for the given locale, in the default timezone.timeStyle
- The time DateFormat
style. For example,
DateFormat.SHORT
for "h:mm a" in the US locale.locale
- The locale or null
for the current locale.public static DateFormat getTimeInstance(int timeStyle, com.ibm.icu.util.ULocale locale, TimeZone timeZone)
DateFormat
style for the given locale and timezone.timeStyle
- The time DateFormat
style. For example,
DateFormat.SHORT
for "h:mm a" in the US locale.locale
- The locale or null
for the current locale.timeZone
- The timezone or null
for the default timezone.public static DateFormat getDateTimeInstance()
public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
DateFormat
styles in the current locale and default timezone.dateStyle
- The date DateFormat
style. For example,
DateFormat.SHORT
for "M/d/yy" in the US locale.timeStyle
- The time DateFormat
style. For example,
DateFormat.SHORT
for "h:mm a" in the US locale.public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, com.ibm.icu.util.ULocale locale)
DateFormat
styles for the given locale, in the default timezone.dateStyle
- The date DateFormat
style. For example,
DateFormat.SHORT
for "M/d/yy" in the US locale.timeStyle
- The time DateFormat
style. For example,
DateFormat.SHORT
for "h:mm a" in the US locale.locale
- The locale or null
for the current locale.public static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, com.ibm.icu.util.ULocale locale, TimeZone timeZone)
DateFormat
styles for the given locale and timezone.dateStyle
- The date DateFormat
style. For example,
DateFormat.SHORT
for "M/d/yy" in the US locale.timeStyle
- The time DateFormat
style. For example,
DateFormat.SHORT
for "h:mm a" in the US locale.locale
- The locale or null
for the current locale.timeZone
- The timezone or null
for the default timezone.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.