public class TemporalPeriodParsingUtility extends Object
<dcterms:temporal xsi:type="dcterms:Period">
start=1999-09-25T14:20+10:00; end=1999-09-25T16:40+10:00; scheme=W3C-DTF;
</dcterms:temporal>
Supports temporal strings following the W3C-DTF scheme, meaning the patterns specified here:
https://www.w3.org/TR/NOTE-datetime
Actually supports a somewhat larger superset of those; see ISODateTimeFormat.dateTimeParser()
Modifier and Type | Field and Description |
---|---|
static String |
END_FIELD |
static String |
SCHEME_FIELD |
static String |
START_FIELD |
static String |
W3C_DTF_SCHEME |
Constructor and Description |
---|
TemporalPeriodParsingUtility() |
Modifier and Type | Method and Description |
---|---|
String |
extractTextValue(Document doc,
XPathExpression xPathExpression)
Returns the text from the given doc, extracted with the given xPathExpression.
|
String |
formatDate(String dateString,
String scheme)
Converts a dateString to a valid solr consumable format.
|
protected String |
getFieldValue(String text,
String fieldName)
Extracts the value for the fieldName from the text.
|
String |
getFormattedEndDate(String text,
String scheme)
Returns a formatted end date value for the given text.
|
String |
getFormattedStartDate(String text,
String scheme)
Returns a formatted start date value for the given text.
|
String |
getScheme(String text)
Returns the scheme value from the given text.
|
public static final String START_FIELD
public static final String END_FIELD
public static final String SCHEME_FIELD
public static final String W3C_DTF_SCHEME
public String extractTextValue(Document doc, XPathExpression xPathExpression)
protected String getFieldValue(String text, String fieldName)
fieldName=fieldValue;and may be located anywhere in the text.
text
- the text to searchfieldName
- the name of the field whose value we want returnedpublic String getScheme(String text)
scheme=W3C-DTF;will return "W3C-DTF" May be null if not present in text.
public String getFormattedStartDate(String text, String scheme)
text
- the text to search for the beginDatescheme
- the format beginDate's value is expected inpublic String getFormattedEndDate(String text, String scheme)
text
- the text to search for the beginDatescheme
- the format endDate's value is expected inpublic String formatDate(String dateString, String scheme)
dateString
- the date String, format specified by scheme paramscheme
- the format of dateString, null defaults to W3C-DTFCopyright © 2022. All rights reserved.