Class AnyDateParser
- java.lang.Object
-
- de.undercouch.citeproc.helper.time.AnyDateParser
-
public class AnyDateParser extends java.lang.ObjectParses 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 java.time.temporal.TemporalAccessorparse(java.lang.String date)Parse a string containing a date in almost any known international format.static java.time.temporal.TemporalAccessorparse(java.lang.String date, java.util.Locale locale)Parse a string containing a date in almost any known international format.
-
-
-
Method Detail
-
parse
public static java.time.temporal.TemporalAccessor parse(java.lang.String date) throws java.lang.IllegalArgumentExceptionParse 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:
java.lang.IllegalArgumentException- if the date could not be parsed
-
parse
public static java.time.temporal.TemporalAccessor parse(java.lang.String date, java.util.Locale locale) throws java.lang.IllegalArgumentExceptionParse 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:
java.lang.IllegalArgumentException- if the date could not be parsed
-
-