Package org.apache.calcite.util
Class DateString
- java.lang.Object
-
- org.apache.calcite.util.DateString
-
- All Implemented Interfaces:
java.lang.Comparable<DateString>
public class DateString extends java.lang.Object implements java.lang.Comparable<DateString>
Date literal.Immutable, internally represented as a string (in ISO format).
-
-
Constructor Summary
Constructors Modifier Constructor Description DateString(int year, int month, int day)
Creates a DateString for year, month, day values.DateString(java.lang.String v)
Creates a DateString.private
DateString(java.lang.String v, boolean ignore)
Internal constructor, no validation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(DateString o)
boolean
equals(java.lang.Object o)
static DateString
fromCalendarFields(java.util.Calendar calendar)
Creates a DateString from a Calendar.static DateString
fromDaysSinceEpoch(int days)
Creates a DateString that is a given number of days since the epoch.private int
getDay()
int
getDaysSinceEpoch()
Returns the number of days since the epoch.long
getMillisSinceEpoch()
Returns the number of milliseconds since the epoch.private int
getMonth()
private int
getYear()
int
hashCode()
java.util.Calendar
toCalendar()
java.lang.String
toString()
private static java.lang.String
ymd(int year, int month, int day)
Validates a year-month-date and converts to a string.
-
-
-
Constructor Detail
-
DateString
private DateString(java.lang.String v, boolean ignore)
Internal constructor, no validation.
-
DateString
public DateString(java.lang.String v)
Creates a DateString.
-
DateString
public DateString(int year, int month, int day)
Creates a DateString for year, month, day values.
-
-
Method Detail
-
ymd
private static java.lang.String ymd(int year, int month, int day)
Validates a year-month-date and converts to a string.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(@Nonnull DateString o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<DateString>
-
fromCalendarFields
public static DateString fromCalendarFields(java.util.Calendar calendar)
Creates a DateString from a Calendar.
-
getDaysSinceEpoch
public int getDaysSinceEpoch()
Returns the number of days since the epoch.
-
getYear
private int getYear()
-
getMonth
private int getMonth()
-
getDay
private int getDay()
-
fromDaysSinceEpoch
public static DateString fromDaysSinceEpoch(int days)
Creates a DateString that is a given number of days since the epoch.
-
getMillisSinceEpoch
public long getMillisSinceEpoch()
Returns the number of milliseconds since the epoch. Always a multiple of 86,400,000 (the number of milliseconds in a day).
-
toCalendar
public java.util.Calendar toCalendar()
-
-