java.lang.Object
com.pervasive.datarush.encoding.text.DateTimeFormatting
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
FieldsModifier and TypeFieldDescriptionstatic final intThe default java base year used for two-digit year values,2000. -
Constructor Summary
ConstructorsConstructorDescriptionDateTimeFormatting(String pattern) 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 TypeMethodDescriptionintGets 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.booleanIndicates whether parsing is to be lenient with respect to well-formed but invalid values.voidsetBaseYear(int year) Specifies the year defining the base value for two-digit dates.voidsetLenient(boolean lenient) Specifies whether parsing of values should be lenient.voidsetPattern(String pattern) Specifies the format pattern to use when parsing or formatting date/time values.
-
Field Details
-
DEFAULT_BASE_YEAR
public static final int DEFAULT_BASE_YEARThe default java base year used for two-digit year values,2000.- See Also:
-
-
Constructor Details
-
DateTimeFormatting
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
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 uselenient- indicates whether parsing should be lenient.
-
DateTimeFormatting
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 usebaseYear- the base year of the 100-year period used by two-digit year values
-
-
Method Details
-
setPattern
Specifies the format pattern to use when parsing or formatting date/time values.- Parameters:
pattern- the format pattern to use
-
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 rangeyearandyear+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
-