@API.Public public final class ODate extends Object implements Comparable<ODate>, Serializable
DATE
type.Constructor and Description |
---|
ODate(Date date)
Constructs an
ODate instance from a java.util.Date using
exactly the same field values. |
ODate(int year,
int month,
int dayOfMonth)
Constructs an
ODate instance set to the specified year, month and
day of the month. |
ODate(long epoh)
Constructs an
ODate instance from the milliseconds value since the
Unix epoch. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ODate o) |
boolean |
equals(Object obj) |
static ODate |
fromDaysSinceEpoch(int daysSinceEpoch)
Return an
ODate instance from the specified number of days since epoch. |
int |
getDayOfMonth() |
int |
getMonth() |
int |
getYear() |
int |
hashCode() |
static ODate |
parse(String dateStr)
Parses and return an instance of
ODate from the specified string. |
Date |
toDate()
Get this DATE as a
Date in the default timezone. |
String |
toDateStr()
Returns a string representation of this date in ISO8601 format (yyyy-MM-dd).
|
int |
toDaysSinceEpoch() |
String |
toString() |
String |
toString(String pattern)
Returns a string representation of this date using the specified format pattern.
|
public ODate(int year, int month, int dayOfMonth)
ODate
instance set to the specified year, month and
day of the month.year
- the yearmonth
- the month of the year, from 1 to 12dayOfMonth
- the day of the month, from 1 to 31public ODate(long epoh)
ODate
instance from the milliseconds value since the
Unix epoch. The DATE value is set to the calendar date in the default time
zone.epoh
- the milliseconds from 1970-01-01T00:00:00.000 UTCpublic ODate(Date date)
ODate
instance from a java.util.Date
using
exactly the same field values. The DATE value is set to the calendar date
in the default time zone.date
- the Date to extract fields frompublic static ODate parse(String dateStr)
ODate
from the specified string.dateStr
- the string to parseParseException
- if the beginning of the specified string
cannot be parsed.public static ODate fromDaysSinceEpoch(int daysSinceEpoch)
ODate
instance from the specified number of days since epoch.daysSinceEpoch
- the number of days since epochpublic int getYear()
Date
as an int
.public int getMonth()
Date
as an int
.public int getDayOfMonth()
Date
as an int
.public int toDaysSinceEpoch()
public Date toDate()
Date
in the default timezone.
The time fields of the Date
object is set to Unix 0.public String toDateStr()
public String toString(String pattern)
pattern
- the pattern specificationpublic int compareTo(ODate o)
compareTo
in interface Comparable<ODate>
Copyright © 2015–2018 MapR Technologies, Inc.. All rights reserved.