|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.stanford.nlp.ie.pascal.ISODateInstance
public class ISODateInstance
Represents dates and times according to ISO8601 standard while also allowing for wild cards - e.g., can represent "21 June" without a year (Standard ISO8601 only allows removing less precise annotations (e.g., 200706 rather than 20070621 but not a way to represent 0621 without a year)
Format stores date and time separately since the majority of current use cases involve only one of these items. Standard ISO 8601 instead requires <date>T<time>. Ranges are specified within the strings via forward slash. For example 6 June - 8 June is represented ****0606/****0608. 6 June onward is ****0606/ and until 8 June is /****0608.
| Nested Class Summary | |
|---|---|
static class |
ISODateInstance.DateField
Enum for the fields * |
| Field Summary | |
|---|---|
static java.lang.String |
BOUNDED_RANGE
|
static int |
DAY_OF_HALF_MONTH
|
static java.util.Map<java.lang.Integer,java.lang.Integer> |
daysPerMonth
|
static int |
LAST_DAY_OF_MONTH
|
static java.lang.String |
LAST_MONTH_OF_YEAR
|
static java.lang.String |
MONTH_OF_HALF_YEAR
|
static java.lang.String |
NO_RANGE
|
static java.lang.String |
OPEN_RANGE_AFTER
|
static java.lang.String |
OPEN_RANGE_BEFORE
|
static java.util.Map<java.lang.String,Pair<ISODateInstance.DateField,java.lang.Integer>> |
relativeDateMap
Map for mapping a relativeDate String to a pair with the field that should be modified and the amount to modify it * |
| Constructor Summary | |
|---|---|
ISODateInstance()
Creates an empty date instance; you probably don't want this in most cases. |
|
ISODateInstance(ISODateInstance start,
ISODateInstance end)
Constructor for a range of dates, beginning at date start and finishing at date end |
|
ISODateInstance(ISODateInstance referenceDate,
java.lang.String relativeDate)
Construct a new ISODate based on its relation to a referenceDate. |
|
ISODateInstance(java.lang.String date)
Takes a string that represents a date, and attempts to normalize it into ISO 8601-compatible format. |
|
ISODateInstance(java.lang.String date,
java.lang.String openRangeMarker)
|
|
| Method Summary | |
|---|---|
boolean |
contains(ISODateInstance other)
Returns true iff this date contains the date represented by other. |
boolean |
extractDay(java.lang.String inputDate)
|
boolean |
extractFields(java.lang.String inputDate)
Uses regexp matching to match month, day, and year fields TODO: Find a way to mark what;s already been handled in the string |
boolean |
extractMonth(java.lang.String inputDate)
|
boolean |
extractWeekday(java.lang.String inputDate)
This is a backup method if everything else fails. |
boolean |
extractYear(java.lang.String inputDate)
|
static ISODateInstance |
fromDateString(java.lang.String date)
Takes a string already formatted in ISODateInstance format (such as one previously written out using toString) and creates a new date instance from it |
java.lang.String |
getDateString()
Provided for backwards compatibility with DateInstance; returns the same thing as toString() |
java.lang.String |
getEndDate()
Returns this date or if it is a range, the date the range ends. |
java.lang.String |
getStartDate()
Returns this date or if it is a range, the date the range starts. |
boolean |
isAfter(java.lang.String dateString)
Returns true if this date instance is after the given dateString. |
static boolean |
isCompatible(java.lang.String date1,
java.lang.String date2)
Returns true iff date1 could represent the same value as date2 e.g. |
boolean |
isCompatibleDate(ISODateInstance other)
|
boolean |
isDayCompatible(ISODateInstance other)
Looks if the days for the two dates are compatible. |
boolean |
isMonthCompatible(ISODateInstance other)
Looks if the months for the two dates are compatible. |
boolean |
isRange()
Returns true iff this date represents a range The range must have at least a start or end date, but is not guaranteed to have both |
boolean |
isUnparseable()
Returns true iff we were unable to parse the input String associated with this date; in that case, we just store the input string and shortcircuit all of the comparison methods |
boolean |
isYearCompatible(ISODateInstance other)
Looks if the years for the two dates are compatible. |
static void |
main(java.lang.String[] args)
For testing only |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String OPEN_RANGE_AFTER
public static final java.lang.String OPEN_RANGE_BEFORE
public static final java.lang.String BOUNDED_RANGE
public static final java.lang.String NO_RANGE
public static final int DAY_OF_HALF_MONTH
public static final int LAST_DAY_OF_MONTH
public static final java.lang.String MONTH_OF_HALF_YEAR
public static final java.lang.String LAST_MONTH_OF_YEAR
public static final java.util.Map<java.lang.String,Pair<ISODateInstance.DateField,java.lang.Integer>> relativeDateMap
public static final java.util.Map<java.lang.Integer,java.lang.Integer> daysPerMonth
| Constructor Detail |
|---|
public ISODateInstance()
public ISODateInstance(java.lang.String date)
public ISODateInstance(java.lang.String date,
java.lang.String openRangeMarker)
public ISODateInstance(ISODateInstance start,
ISODateInstance end)
public ISODateInstance(ISODateInstance referenceDate,
java.lang.String relativeDate)
| Method Detail |
|---|
public static ISODateInstance fromDateString(java.lang.String date)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getDateString()
public boolean extractFields(java.lang.String inputDate)
public boolean isRange()
public boolean isUnparseable()
public java.lang.String getStartDate()
public java.lang.String getEndDate()
public static boolean isCompatible(java.lang.String date1,
java.lang.String date2)
public boolean contains(ISODateInstance other)
public boolean isAfter(java.lang.String dateString)
public boolean isCompatibleDate(ISODateInstance other)
public boolean isYearCompatible(ISODateInstance other)
public boolean isMonthCompatible(ISODateInstance other)
public boolean isDayCompatible(ISODateInstance other)
public boolean extractYear(java.lang.String inputDate)
public boolean extractMonth(java.lang.String inputDate)
public boolean extractDay(java.lang.String inputDate)
public boolean extractWeekday(java.lang.String inputDate)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||