public class ISODateInstance extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ISODateInstance.DateField
Enum for the fields *
|
Modifier and Type | Field and Description |
---|---|
static String |
BOUNDED_RANGE |
static int |
DAY_OF_HALF_MONTH |
static Map<Integer,Integer> |
daysPerMonth |
static int |
LAST_DAY_OF_MONTH |
static String |
LAST_MONTH_OF_YEAR |
static String |
MONTH_OF_HALF_YEAR |
static String |
NO_RANGE |
static String |
OPEN_RANGE_AFTER |
static String |
OPEN_RANGE_BEFORE |
static Map<String,Pair<ISODateInstance.DateField,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 and Description |
---|
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,
String relativeDate)
Construct a new ISODate based on its relation to a referenceDate.
|
ISODateInstance(String date)
Takes a string that represents a date, and attempts to
normalize it into ISO 8601-compatible format.
|
ISODateInstance(String date,
String openRangeMarker) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(ISODateInstance other)
Returns true iff this date
contains the date represented by other.
|
boolean |
extractDay(String inputDate) |
boolean |
extractFields(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(String inputDate) |
boolean |
extractWeekday(String inputDate)
This is a backup method if everything else fails.
|
boolean |
extractYear(String inputDate) |
static ISODateInstance |
fromDateString(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
|
String |
getDateString()
Provided for backwards compatibility with DateInstance;
returns the same thing as toString()
|
String |
getEndDate()
Returns this date or if it is a range,
the date the range ends.
|
String |
getStartDate()
Returns this date or if it is a range,
the date the range starts.
|
boolean |
isAfter(String dateString)
Returns true if this date instance is after
the given dateString.
|
static boolean |
isCompatible(String date1,
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(String[] args)
For testing only
|
String |
toString() |
public static final String OPEN_RANGE_AFTER
public static final String OPEN_RANGE_BEFORE
public static final String BOUNDED_RANGE
public static final String NO_RANGE
public static final int DAY_OF_HALF_MONTH
public static final int LAST_DAY_OF_MONTH
public static final String MONTH_OF_HALF_YEAR
public static final String LAST_MONTH_OF_YEAR
public static final Map<String,Pair<ISODateInstance.DateField,Integer>> relativeDateMap
public ISODateInstance()
public ISODateInstance(String date)
public ISODateInstance(ISODateInstance start, ISODateInstance end)
public ISODateInstance(ISODateInstance referenceDate, String relativeDate)
public static ISODateInstance fromDateString(String date)
public String getDateString()
public boolean extractFields(String inputDate)
public boolean isRange()
public boolean isUnparseable()
public String getStartDate()
public String getEndDate()
public static boolean isCompatible(String date1, String date2)
public boolean contains(ISODateInstance other)
public boolean isAfter(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(String inputDate)
public boolean extractMonth(String inputDate)
public boolean extractDay(String inputDate)
public boolean extractWeekday(String inputDate)
public static void main(String[] args)