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:
  • Constructor Details

    • 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(String pattern, Locale locale, TimeZone timeZone)
    • 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:
    • 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:
  • Method Details

    • 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 interface FastFormat
      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 interface FastFormat
      Parameters:
      parameters - the parameters for the formatting.
      Returns:
      the formatted string.
    • clone

      public FastDateFormat clone()
      Clones the formatter.
      Specified by:
      clone in interface FastFormat
      Overrides:
      clone in class Object
      Returns:
      the clone.
    • getTimeZone

      public TimeZone getTimeZone()
    • setTimeZone

      public void setTimeZone(TimeZone timeZone)