Package org.dspace.util
Class MultiFormatDateParser
java.lang.Object
org.dspace.util.MultiFormatDateParser
Attempt to parse date strings in a variety of formats. This uses an external
list of regular expressions and associated DateTimeFormatter patterns. Inject
the list as pairs of strings using
setPatterns(java.util.Map<java.lang.String, java.lang.String>). parse(java.lang.String) walks
the provided list in the order provided and tries each entry against a String.
Dates are parsed as being in the UTC zone.- Author:
- mwood
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic ZonedDateTimeCompare a string to each injected regular expression in entry order, and when it matches, attempt to parse it using the associated format.voidsetPatterns(Map<String, String> patterns)
-
Constructor Details
-
MultiFormatDateParser
public MultiFormatDateParser()
-
-
Method Details
-
setPatterns
-
parse
Compare a string to each injected regular expression in entry order, and when it matches, attempt to parse it using the associated format.- Parameters:
dateString- the supposed date to be parsed.- Returns:
- the result of the first successful parse, or
nullif none.
-
main
- Throws:
IOException
-