Class AnyDateParser
- java.lang.Object
-
- de.undercouch.citeproc.helper.time.AnyDateParser
-
public class AnyDateParser extends Object
Parses strings containing dates in almost any known international format.- Author:
- Michel Kraemer
-
-
Constructor Summary
Constructors Constructor Description AnyDateParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TemporalAccessorparse(String date)Parse a string containing a date in almost any known international format.static TemporalAccessorparse(String date, Locale locale)Parse a string containing a date in almost any known international format.
-
-
-
Method Detail
-
parse
public static TemporalAccessor parse(String date) throws IllegalArgumentException
Parse a string containing a date in almost any known international format. Parses at most year, month, and date and returns them in aTemporalAccessorobject. This object may not contain all fields if the string does not contain them as well. For example, if the string is "2014-10", the object will only contain a year and a month but not a day.- Parameters:
date- the string containing the date- Returns:
- the parsed date
- Throws:
IllegalArgumentException- if the date could not be parsed
-
parse
public static TemporalAccessor parse(String date, Locale locale) throws IllegalArgumentException
Parse a string containing a date in almost any known international format. Parses at most year, month, and date and returns them in aTemporalAccessorobject. This object may not contain all fields if the string does not contain them as well. For example, if the string is "2014-10", the object will only contain a year and a month but not a day.- Parameters:
date- the string containing the datelocale- the locale to use for parsing (used to parse month names and to determine if the locale prefers the month to be given before the day in the string to parse or the other way around)- Returns:
- the parsed date
- Throws:
IllegalArgumentException- if the date could not be parsed
-
-