public class DateParser extends Object
By default, parsed values must be both syntactically and semantically correct. However, the parser can be configured to be lenient and allow values in the right format to be parsed without error. If parsing is lenient, these values will be interpreted as additional units of the field in question applied to the limit for that field. This "rollover" is applied in order of precision, from least to most precise field. For instance, under lenient parsing:
Parsing is done using the
Joda time library which uses a similar format to that described in
SimpleDateFormat
. Most specifiers compatible with the JDK will
be compatible with Joda time, the notable exceptions being:
Constructor and Description |
---|
DateParser(DateTimeFormatting format,
String nullIndicator)
Creates a parser using the specified format.
|
DateParser(String format)
Creates a parser using the specified format.
|
Modifier and Type | Method and Description |
---|---|
String |
getParseError()
When
parse method returns false
this method can be used to retrieve the specific error
message detailing why the parsing failed. |
boolean |
parse(String text)
Parses the given text string into a token value.
|
protected void |
setParseError(String msg) |
void |
setTarget(ScalarSettable output)
Sets the buffer for holding parsed values.
|
public DateParser(String format)
format
- the input format to parsepublic DateParser(DateTimeFormatting format, String nullIndicator)
format
- the input format to parsenullIndicator
- the text value representing nulllenient
- indicates whether to be lenient about accepting
values having the correct syntax, but not having a valid mapping.public final void setTarget(ScalarSettable output)
TokenParser
setTarget
in interface TokenParser
output
- the value buffer in which to store parsed
valuespublic final boolean parse(String text)
TokenParser
getParseError
method.parse
in interface TokenParser
text
- text string to convert. Callers should not
assume it is safe to pass null
.true
if the parsing succeeded,
false
otherwise.protected final void setParseError(String msg)
public final String getParseError()
TokenParser
parse
method returns false
this method can be used to retrieve the specific error
message detailing why the parsing failed. If the last
parse was successful an empty string will be returnedgetParseError
in interface TokenParser
parse
.Copyright © 2021 Actian Corporation. All rights reserved.