Class DateTimeFormatting

java.lang.Object
com.pervasive.datarush.encoding.text.DateTimeFormatting

public class DateTimeFormatting extends Object
Describes the formatting of a string representing a date/time value. Primarily, this provides the formatting pattern used for laying out the various fields. Additional properties related to the parsing of values are also provided:
  • Whether parsing is lenient. That is, whether values which are syntactically correct, such as 2/30/1999, are parsed without error. If allowed, values are adjusted to valid ones; in this case, 3/2/1999 - two (30-28) days after 2/28/1999. By default, parsing is strict.
  • The base year for two-digit year values. Dates are assumed to be within the 100-year period starting on January 1st of the base year. By default, 2000 is the base year used by Java, meaning two-digit years represent values between 2000 and 2099.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default java base year used for two-digit year values, 2000.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Defines a format using the specified pattern.
    DateTimeFormatting(String pattern, boolean lenient)
    Defines a format using the specified pattern and parsing leniency.
    DateTimeFormatting(String pattern, int baseYear)
    Defines a format using the specified pattern and pivot year.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the base year defining the start of the 100-year period assumed for two-digit year values.
    Gets the format pattern used for parsing and formatting date/time values.
    boolean
    Indicates whether parsing is to be lenient with respect to well-formed but invalid values.
    void
    setBaseYear(int year)
    Specifies the year defining the base value for two-digit dates.
    void
    setLenient(boolean lenient)
    Specifies whether parsing of values should be lenient.
    void
    setPattern(String pattern)
    Specifies the format pattern to use when parsing or formatting date/time values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_BASE_YEAR

      public static final int DEFAULT_BASE_YEAR
      The default java base year used for two-digit year values, 2000.
      See Also:
  • Constructor Details

    • DateTimeFormatting

      public DateTimeFormatting(String pattern)
      Defines a format using the specified pattern. Parsing will be strict, rejecting syntactically correct but otherwise invalid values such as 4/31/1999 or 13:61:00. Two digit years will NOT be assumed by default
      Parameters:
      pattern - the text format to use
    • DateTimeFormatting

      public DateTimeFormatting(String pattern, boolean lenient)
      Defines a format using the specified pattern and parsing leniency. Two digit years will be assumed to be between 1950 and 2049.
      Parameters:
      pattern - the text format to use
      lenient - indicates whether parsing should be lenient.
    • DateTimeFormatting

      public DateTimeFormatting(String pattern, int baseYear)
      Defines a format using the specified pattern and pivot year. Parsing will be strict, rejecting syntactically correct but otherwise invalid values such as 4/31/1999 or 13:61:00.
      Parameters:
      pattern - the text format to use
      baseYear - the base year of the 100-year period used by two-digit year values
  • Method Details

    • setPattern

      public void setPattern(String pattern)
      Specifies the format pattern to use when parsing or formatting date/time values.
      Parameters:
      pattern - the format pattern to use
    • getPattern

      public String getPattern()
      Gets the format pattern used for parsing and formatting date/time values.
      Returns:
      the format pattern to use
    • setLenient

      public void setLenient(boolean lenient)
      Specifies whether parsing of values should be lenient. That is, whether to parse values which match the formatting pattern but do not represent real date/time values, such as 4/31/1999 or 13:61:00. If parsing is lenient, values will "rollover" into the units of the next lower unit of precision. Thus 4/31/1999 will parse as 5/1/1999 and 13:61:00 as 14:01:00.
      Parameters:
      lenient - indicates whether parsing should be lenient.
    • isLenient

      public boolean isLenient()
      Indicates whether parsing is to be lenient with respect to well-formed but invalid values.
      Returns:
      whether parsing should be lenient
    • setBaseYear

      public void setBaseYear(int year)
      Specifies the year defining the base value for two-digit dates. When parsing, years will be assumed to be within the range year and year+99.
      Parameters:
      year - the base of the range for parsed year values
    • getBaseYear

      public int getBaseYear()
      Gets the base year defining the start of the 100-year period assumed for two-digit year values.
      Returns:
      the base year of the valid period