public class DateTime extends java.lang.Object implements IDate, java.lang.Comparable<DateTime>, java.lang.Cloneable, java.io.Serializable
Date.Formatter.format(DateTime),
DateFormat.format(DateTime),
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_NAME |
static int |
MAX_HOUR |
static int |
MAX_MILLISECOND |
static int |
MAX_MINUTE |
static int |
MAX_MONTH |
static int |
MAX_SECOND |
static int |
MAX_YEAR |
| Constructor and Description |
|---|
DateTime() |
DateTime(int year,
int month,
int date)
Constructs a
DateTime with zero in the time fields (HMS). |
DateTime(int year,
int month,
int date,
int hours,
int minutes)
Constructs a
DateTime with zero in the time fields (HMS). |
DateTime(int year,
int month,
int date,
int hours,
int minutes,
int seconds)
Constructs a
DateTime with zero in the time fields (HMS). |
DateTime(int year,
int month,
int date,
int hours,
int minutes,
int seconds,
int millis)
Constructs a
DateTime with all its fields initialized. |
DateTime(int year,
int month,
int date,
int hours,
int minutes,
int seconds,
int millis,
java.lang.String timeZone)
Constructs a
DateTime with all its fields initialized. |
DateTime(java.lang.String string) |
DateTime(java.lang.String string,
boolean fillToDayEnd) |
DateTime(java.time.ZonedDateTime zdt)
Constructs a
DateTime from a ZonedDateTime |
| Modifier and Type | Method and Description |
|---|---|
DateTime |
add(long elapsed)
Adds the given number of milliseconds to this date time object
|
boolean |
after(DateTime dt) |
boolean |
afterOrEquals(DateTime dt) |
boolean |
before(DateTime dt) |
boolean |
beforeOrEquals(DateTime dt) |
int |
compareTo(DateTime dt) |
DateTime |
decDate() |
DateTime |
decMonth() |
DateTime |
decYear() |
DateTime |
duplicate()
Makes a copy of this instance.
|
boolean |
equals(java.lang.Object obj) |
int |
getDate() |
int |
getHours() |
int |
getMilliseconds() |
int |
getMinutes() |
int |
getMonth() |
int |
getSeconds() |
java.lang.String |
getTimeZone() |
int |
getYear() |
int |
hashCode() |
DateTime |
incDate() |
DateTime |
incMonth() |
DateTime |
incYear() |
boolean |
isSameDay(DateTime dt) |
static DateTime |
parse(java.lang.String string)
Parses the given String as a
DateTime, returning null for blank strings |
void |
setDate(int date)
Sets the day of the month.
|
void |
setHMSM(int hours,
int minutes,
int seconds,
int milliseconds)
Sets only the time part (H=hours, M=minutes, S=seconds, M=milliseconds) without changing the date part (YMD)
|
void |
setHours(int hours) |
void |
setMilliseconds(int milliseconds) |
void |
setMinutes(int minutes) |
void |
setMonth(int month) |
void |
setSeconds(int seconds) |
void |
setTimeZone(java.lang.String timeZone) |
void |
setYear(int year) |
void |
setYMD(int year,
int month,
int date)
Sets only the date part (Y=year, M=month, D=date (day of month)) without change the time part (HMS)
|
java.lang.String |
toString() |
public static final java.lang.String CLASS_NAME
public static final int MAX_YEAR
public static final int MAX_MONTH
public static final int MAX_HOUR
public static final int MAX_MINUTE
public static final int MAX_SECOND
public static final int MAX_MILLISECOND
public DateTime()
public DateTime(int year,
int month,
int date)
DateTime with zero in the time fields (HMS).month - it must be between 0 and 11 (same as Date)date - it must be between 1 and 31 (same as Date)public DateTime(int year,
int month,
int date,
int hours,
int minutes)
DateTime with zero in the time fields (HMS).month - it must be between 0 and 11 (same as Date)date - it must be between 1 and 31 (same as Date)hours - it must be between 0 and 23 (Hour in day)minutes - it must be between 0 and 59public DateTime(int year,
int month,
int date,
int hours,
int minutes,
int seconds)
DateTime with zero in the time fields (HMS).month - it must be between 0 and 11 (same as Date)date - it must be between 1 and 31 (same as Date)hours - it must be between 0 and 23 (Hour in day)minutes - it must be between 0 and 59seconds - it must be between 0 and 59public DateTime(int year,
int month,
int date,
int hours,
int minutes,
int seconds,
int millis)
DateTime with all its fields initialized.month - it must be between 0 and 11 (same as Date)date - it must be between 1 and 31 (same as Date)hours - it must be between 0 and 23 (Hour in day)minutes - it must be between 0 and 59seconds - it must be between 0 and 59millis - it must be between 0 and 999public DateTime(int year,
int month,
int date,
int hours,
int minutes,
int seconds,
int millis,
java.lang.String timeZone)
DateTime with all its fields initialized.month - it must be between 0 and 11 (same as Date)date - it must be between 1 and 31 (same as Date)hours - it must be between 0 and 23 (Hour in day)minutes - it must be between 0 and 59seconds - it must be between 0 and 59millis - it must be between 0 and 999timeZone - the timezone. Null means resolving the current user's configured timezonepublic DateTime(java.lang.String string)
public DateTime(java.lang.String string,
boolean fillToDayEnd)
public DateTime(java.time.ZonedDateTime zdt)
DateTime from a ZonedDateTimepublic static DateTime parse(java.lang.String string)
DateTime, returning null for blank stringspublic DateTime add(long elapsed) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if elapsed time is negative.public boolean after(DateTime dt)
public boolean afterOrEquals(DateTime dt)
public boolean before(DateTime dt)
public boolean beforeOrEquals(DateTime dt)
public int compareTo(DateTime dt)
compareTo in interface java.lang.Comparable<DateTime>public DateTime decDate()
public DateTime decMonth()
public DateTime decYear()
public DateTime duplicate()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int getDate()
public int getHours()
public int getMilliseconds()
public int getMinutes()
public int getMonth()
public int getSeconds()
public java.lang.String getTimeZone()
public int getYear()
public int hashCode()
hashCode in class java.lang.Objectpublic DateTime incDate()
public DateTime incMonth()
public DateTime incYear()
public boolean isSameDay(DateTime dt)
public void setDate(int date)
date - it must be between 1 and 31 (must be a valid value according to the month)public void setHMSM(int hours,
int minutes,
int seconds,
int milliseconds)
hours - it must be between 0 and 23 (Hour in day)public void setHours(int hours)
hours - it must be between 0 and 23 (Hour in day)public void setMilliseconds(int milliseconds)
public void setMinutes(int minutes)
minutes - it must be between 0 and 59public void setMonth(int month)
month - it must be between 0 and 11 (same as Date)public void setSeconds(int seconds)
seconds - it must be between 0 and 59public void setTimeZone(java.lang.String timeZone)
public void setYear(int year)
public void setYMD(int year,
int month,
int date)
month - it must be between 0 and 11 (same as Date)date - it must be between 1 and 31 (same as Date)public java.lang.String toString()
toString in class java.lang.Object