Package de.undercouch.citeproc.bibtex
Class DateParser
- java.lang.Object
-
- de.undercouch.citeproc.bibtex.DateParser
-
public class DateParser extends java.lang.ObjectParses dates- Author:
- Michel Kraemer
-
-
Constructor Summary
Constructors Constructor Description DateParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CSLDatetoDate(java.lang.String dateString)Converts a given date string to aCSLDateobject.static CSLDatetoDate(java.lang.String year, java.lang.String month)Parses the given year and month to aCSLDateobject.static CSLDatetoDateRange(java.lang.String year, java.lang.String month)Parses the given year and month to aCSLDateobject.static CSLDatetoDateSingle(java.lang.String year, java.lang.String month)Parses the given year and month to aCSLDateobject.static inttoMonth(java.lang.String month)Parses the given month string
-
-
-
Method Detail
-
toDate
public static CSLDate toDate(java.lang.String dateString)
Converts a given date string to aCSLDateobject. Does not parse the string but saves it in the CSLDate's raw field.- Parameters:
dateString- the string- Returns:
- the
CSLDateobject
-
toDate
public static CSLDate toDate(java.lang.String year, java.lang.String month)
Parses the given year and month to aCSLDateobject. Handles date ranges such asxx-xxorxx/xxand evenxx-xx/yy-yy.- Parameters:
year- the year to parse. Should be a four-digit number or a String whose last four characters are digits.month- the month to parse. May be a number (1-12), a short month name (JantoDec), or a long month name (JanuarytoDecember). This method is also able to recognize month names in several locales.- Returns:
- the
CSLDateobject or null if both, the year and the month, could not be parsed
-
toDateRange
public static CSLDate toDateRange(java.lang.String year, java.lang.String month)
Parses the given year and month to aCSLDateobject. Handles date ranges such asxx-xx.- Parameters:
year- the year to parse. Should be a four-digit number or a String whose last four characters are digits.month- the month to parse. May be a number (1-12), a short month name (JantoDec), or a long month name (JanuarytoDecember). This method is also able to recognize month names in several locales.- Returns:
- the
CSLDateobject or null if both, the year and the month, could not be parsed
-
toDateSingle
public static CSLDate toDateSingle(java.lang.String year, java.lang.String month)
Parses the given year and month to aCSLDateobject. Does not handle ranges.- Parameters:
year- the year to parse. Should be a four-digit number or a String whose last four characters are digits.month- the month to parse. May be a number (1-12), a short month name (JantoDec), or a long month name (JanuarytoDecember). This method is also able to recognize month names in several locales.- Returns:
- the
CSLDateobject or null if both, the year and the month, could not be parsed
-
toMonth
public static int toMonth(java.lang.String month)
Parses the given month string- Parameters:
month- the month to parse. May be a number (1-12), a short month name (JantoDec), or a long month name (JanuarytoDecember). This method is also able to recognize month names in several locales.- Returns:
- the month's number (
1-12) or-1if the string could not be parsed
-
-