public class DateParser extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DateParser.Component |
protected static class |
DateParser.Mode |
| Modifier and Type | Field and Description |
|---|---|
protected static int |
AM |
protected static DateParser.Component[][] |
DATE_SEQUENCES_DAY_FIRST |
protected static DateParser.Component[][] |
DATE_SEQUENCES_MONTH_FIRST |
protected DateStyle |
m_dateStyle |
protected org.threeten.bp.LocalDate |
m_now |
protected org.threeten.bp.ZoneId |
m_timezone |
protected static Map<String,Integer> |
MONTHS_BY_ALIAS |
protected static int |
PM |
protected static DateParser.Component[][] |
TIME_SEQUENCES |
| Constructor and Description |
|---|
DateParser(org.threeten.bp.LocalDate now,
org.threeten.bp.ZoneId timezone,
DateStyle dateStyle)
Creates a new date parser
|
| Modifier and Type | Method and Description |
|---|---|
org.threeten.bp.temporal.Temporal |
auto(String text)
Returns a date or datetime depending on what information is available
|
protected static List<DateParser.Component[]> |
getPossibleSequences(DateParser.Mode mode,
int length,
DateStyle dateStyle)
Gets possible component sequences in the given mode
|
protected static Map<DateParser.Component,Integer> |
getTokenPossibilities(String token,
DateParser.Mode mode)
Returns all possible component types of a token without regard to its context.
|
protected static Map<String,Integer> |
loadMonthAliases(String file)
Loads month aliases from the given resource file
|
protected static org.threeten.bp.temporal.Temporal |
makeResult(Map<DateParser.Component,Integer> values,
org.threeten.bp.LocalDate now,
org.threeten.bp.ZoneId timezone)
Makes a date or datetime or time object from a map of component values
|
protected org.threeten.bp.temporal.Temporal |
parse(String text,
DateParser.Mode mode)
Returns a date, datetime or time depending on what information is available
|
org.threeten.bp.OffsetTime |
time(String text)
Tries to parse a time value from the given text
|
protected static int |
yearFrom2Digits(int shortYear,
int currentYear)
Converts a relative 2-digit year to an absolute 4-digit year
|
protected static final int AM
protected static final int PM
protected static final DateParser.Component[][] DATE_SEQUENCES_DAY_FIRST
protected static final DateParser.Component[][] DATE_SEQUENCES_MONTH_FIRST
protected static final DateParser.Component[][] TIME_SEQUENCES
protected final org.threeten.bp.LocalDate m_now
protected final org.threeten.bp.ZoneId m_timezone
protected final DateStyle m_dateStyle
public DateParser(org.threeten.bp.LocalDate now,
org.threeten.bp.ZoneId timezone,
DateStyle dateStyle)
now - the now which parsing happens relative totimezone - the timezone in which times are interpreted if input doesn't include an offsetdateStyle - whether dates are usually entered day first or month firstpublic org.threeten.bp.temporal.Temporal auto(String text)
text - the text to parsepublic org.threeten.bp.OffsetTime time(String text)
text - the text to parseprotected org.threeten.bp.temporal.Temporal parse(String text, DateParser.Mode mode)
protected static List<DateParser.Component[]> getPossibleSequences(DateParser.Mode mode, int length, DateStyle dateStyle)
mode - the modelength - the length (only returns sequences of this length)dateStyle - whether dates are usually entered day first or month firstprotected static Map<DateParser.Component,Integer> getTokenPossibilities(String token, DateParser.Mode mode)
token - the token to classifyprotected static org.threeten.bp.temporal.Temporal makeResult(Map<DateParser.Component,Integer> values, org.threeten.bp.LocalDate now, org.threeten.bp.ZoneId timezone)
values - the component valuestimezone - the current timezoneprotected static int yearFrom2Digits(int shortYear,
int currentYear)
shortYear - the relative yearprotected static Map<String,Integer> loadMonthAliases(String file) throws IOException
IOExceptionCopyright © 2016. All rights reserved.