Class FastDateFormat
- java.lang.Object
-
- org.pentaho.reporting.libraries.formatting.FastDateFormat
-
- All Implemented Interfaces:
Serializable
,Cloneable
,FastFormat
public class FastDateFormat extends Object implements FastFormat
A wrapper around the java.text.SimpleDateFormat class. This wrapper limits the possible interactions with the wrapped format class and therefore we can treat the implementation as immutable.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FastDateFormat(int dateStyle, int timeStyle, Locale locale)
Creates a new date-format for the given default date and time style.FastDateFormat(int dateStyle, int timeStyle, Locale locale, TimeZone timeZone)
Creates a new date-format for the given default date and time style along with a TimeZone.FastDateFormat(String pattern)
Creates a new date-format for the given pattern.FastDateFormat(String pattern, Locale locale)
Creates a new date-format for the given pattern and locale.FastDateFormat(String pattern, Locale locale, TimeZone timeZone)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FastDateFormat
clone()
Clones the formatter.String
format(Object parameters)
Formats the given object in a formatter-specific way.Locale
getLocale()
Returns the current locale of the formatter.String
getPattern()
Returns the pattern for the date-format.TimeZone
getTimeZone()
void
setLocale(Locale locale)
Updates the locale of the choice format.void
setTimeZone(TimeZone timeZone)
-
-
-
Constructor Detail
-
FastDateFormat
public FastDateFormat(String pattern)
Creates a new date-format for the given pattern.- Parameters:
pattern
- the pattern string.
-
FastDateFormat
public FastDateFormat(String pattern, Locale locale)
Creates a new date-format for the given pattern and locale.- Parameters:
pattern
- the pattern string.locale
- the locale.
-
FastDateFormat
public FastDateFormat(int dateStyle, int timeStyle, Locale locale)
Creates a new date-format for the given default date and time style.- Parameters:
dateStyle
- the date-style, one of DateFormat#SHORT, DateFormat#MEDIUM, DateFormat#LONG, DateFormat#FULL or -1 for none.timeStyle
- the date-style, one of DateFormat#SHORT, DateFormat#MEDIUM, DateFormat#LONG, DateFormat#FULL or -1 for none.locale
- the locale.- Throws:
IllegalArgumentException
- if both date and time-style are set to -1.- See Also:
DateFormat.getDateTimeInstance(int, int, Locale)
-
FastDateFormat
public FastDateFormat(int dateStyle, int timeStyle, Locale locale, TimeZone timeZone)
Creates a new date-format for the given default date and time style along with a TimeZone.- Parameters:
dateStyle
- the date-style, one of DateFormat#SHORT, DateFormat#MEDIUM, DateFormat#LONG, DateFormat#FULL or -1 for none.timeStyle
- the date-style, one of DateFormat#SHORT, DateFormat#MEDIUM, DateFormat#LONG, DateFormat#FULL or -1 for none.locale
- the locale.timeZone
- the timeZone to which dates are interpreted.- Throws:
IllegalArgumentException
- if both date and time-style are set to -1.- See Also:
DateFormat.getDateTimeInstance(int, int, Locale)
-
-
Method Detail
-
setLocale
public void setLocale(Locale locale)
Updates the locale of the choice format. This has no impact on the result of the choice-format computation.- Parameters:
locale
- the locale, never null.
-
getLocale
public Locale getLocale()
Returns the current locale of the formatter.- Specified by:
getLocale
in interfaceFastFormat
- Returns:
- the current locale, never null.
-
getPattern
public String getPattern()
Returns the pattern for the date-format.- Returns:
- the pattern.
-
format
public String format(Object parameters)
Formats the given object in a formatter-specific way.- Specified by:
format
in interfaceFastFormat
- Parameters:
parameters
- the parameters for the formatting.- Returns:
- the formatted string.
-
clone
public FastDateFormat clone()
Clones the formatter.- Specified by:
clone
in interfaceFastFormat
- Overrides:
clone
in classObject
- Returns:
- the clone.
-
getTimeZone
public TimeZone getTimeZone()
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
-
-