Modifier and Type | Field and Description |
---|---|
static DateTime |
MaxValue
Represents the largest possible value of
DateTime . |
static DateTime |
MinValue
Represents the smallest possible value of
DateTime . |
Constructor and Description |
---|
DateTime(java.util.Date date)
Initializes a new instance of the
DateTime class, representing specified Date. |
DateTime(int year,
int month,
int day)
Initializes a new instance of the
DateTime class with the specified values. |
DateTime(int year,
int month,
int day,
int hour,
int minute,
int second)
Initializes a new instance of the
DateTime class with the specified values. |
DateTime(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Initializes a new instance of the
DateTime class with the specified values. |
DateTime(java.time.LocalDateTime dateTime)
Initializes a new instance of the
DateTime class, storing specified LocalDateTime. |
DateTime(long ticks)
Initializes a new instance of the
DateTime class with the specified number of ticks. |
Modifier and Type | Method and Description |
---|---|
DateTime |
add(Duration value)
|
DateTime |
addDays(double value)
Returns a new
DateTime that adds the specified number of
days to this instance. |
DateTime |
addDays(long value)
Returns a new
DateTime that adds the specified number of
days to this instance. |
DateTime |
addHours(double value)
Returns a new
DateTime that adds the specified number of
hours to this instance. |
DateTime |
addHours(long value)
Returns a new
DateTime that adds the specified number of
hours to this instance. |
DateTime |
addMilliseconds(double value)
Returns a new
DateTime that adds the specified number of
milliseconds to this instance. |
DateTime |
addMilliseconds(long value)
Returns a new
DateTime that adds the specified number of
milliseconds to this instance. |
DateTime |
addMinutes(double value)
Returns a new
DateTime that adds the specified number of
minutes to this instance. |
DateTime |
addMinutes(long value)
Returns a new
DateTime that adds the specified number of
minutes to this instance. |
DateTime |
addMonths(long value)
Returns a new
DateTime that adds the specified number of
months to this instance. |
DateTime |
addSeconds(double value)
Returns a new
DateTime that adds the specified number of
seconds to this instance. |
DateTime |
addSeconds(long value)
Returns a new
DateTime that adds the specified number of
seconds to this instance. |
DateTime |
addTicks(long value)
Returns a new
DateTime that adds the specified number of
ticks to this instance. |
DateTime |
addYears(int value)
Returns a new
DateTime that adds the specified number of
years to this instance. |
DateTime |
clone()
Cloneable.clone implementation. |
int |
compareTo(DateTime o)
Comparable.compareTo implementation. |
static int |
daysInMonth(int year,
int month)
Returns the number of days in the specified month and year.
|
boolean |
equals(java.lang.Object value)
Object.equals override. |
DateTime |
getDate()
Gets the date component of this instance.
|
int |
getDay()
Gets the day of month component of the date (1-31).
|
DayOfWeek |
getDayOfWeek()
Gets the day of the week represented by this instance.
|
int |
getDayOfYear()
Gets the day of the year represented by this instance.
|
int |
getHour()
Gets the hour component of the date (0-23).
|
int |
getMillisecond()
Gets the millisecond component of the date (0-999).
|
int |
getMinute()
Gets the minute component of the date (0-59).
|
int |
getMonth()
Gets the month component of the date (1-12).
|
int |
getSecond()
Gets the second component of the date (0-59).
|
long |
getTicks()
Gets the total number of ticks in this instance.
|
Duration |
getTimeOfDay()
Gets the time of the day of this instance.
|
int |
getWeekOfYear()
Gets the week of the year for the current date.
|
int |
getYear()
Gets the year component of the date.
|
int |
hashCode()
Object.hashCode override. |
static boolean |
isLeapYear(int year)
Returns a value indicating whether the specified year is a leap year.
|
boolean |
isLessThan(DateTime d)
|
boolean |
isLessThanOrEqual(DateTime d)
|
boolean |
isLocalTime()
Gets a value indicating whether the time represented by this instance
is a local time.
|
boolean |
isUtcTime()
Gets a value indicating whether the time represented by this instance
is a UTC time.
|
boolean |
isWeekend() |
static DateTime |
now()
Gets a
DateTime object that is set to the current date and time
in the default time zone and locale. |
static DateTime |
op_Addition(DateTime d,
Duration t)
Adds a specified time interval to a specified date and time, yielding a new
date and time.
|
static boolean |
op_Equality(DateTime d1,
DateTime d2)
Determines whether two specified instances of
DateTime are equal. |
static boolean |
op_GreaterThan(DateTime d1,
DateTime d2)
|
static boolean |
op_GreaterThanOrEqual(DateTime d1,
DateTime d2)
|
static boolean |
op_Inequality(DateTime d1,
DateTime d2)
Determines whether two specified instances of
DateTime are not equal. |
static boolean |
op_LessThan(DateTime d1,
DateTime d2)
|
static boolean |
op_LessThanOrEqual(DateTime d1,
DateTime d2)
|
static Duration |
op_Subtraction(DateTime d1,
DateTime d2)
Subtracts a specified date and time from another specified date and time
and returns a time interval.
|
static DateTime |
op_Subtraction(DateTime d,
Duration t)
Subtracts a specified time interval from a specified date and time and returns
a new date and time.
|
Duration |
subtract(DateTime date)
Subtracts the specified date and time from this instance.
|
DateTime |
subtract(Duration duration)
Subtracts the specified duration from this instance.
|
static DateTime |
today()
Gets a
DateTime object that represents the current date
in the default time one and locale. |
java.util.Calendar |
toJavaCalendar()
Converts the stored date and time to a Calendar object.
|
java.time.LocalDateTime |
toJavaDateTime()
Returns the stored LocalDateTime value.
|
DateTime |
toLocalTime()
Converts the value of the current
DateTime object to local time. |
java.lang.String |
toLongDateString()
Converts the value of the current
DateTime object to its equivalent
long date string representation. |
java.lang.String |
toLongDateString(java.util.Locale locale)
Converts the value of the current
DateTime object to its equivalent
long date string representation. |
java.lang.String |
toLongTimeString()
Converts the value of the current
DateTime object to its equivalent
long time string representation. |
java.lang.String |
toLongTimeString(java.util.Locale locale)
Converts the value of the current
DateTime object to its equivalent
long time string representation. |
java.lang.String |
toShortDateString()
Converts the value of the current
DateTime object to its equivalent
short date string representation. |
java.lang.String |
toShortDateString(java.util.Locale locale)
Converts the value of the current
DateTime object to its equivalent
short date string representation. |
java.lang.String |
toShortTimeString()
Converts the value of the current
DateTime object to its equivalent
short time string representation. |
java.lang.String |
toShortTimeString(java.util.Locale locale)
Converts the value of the current
DateTime object to its equivalent
short time string representation. |
java.lang.String |
toString()
Converts the value of the current
DateTime object to its equivalent
string representation. |
java.lang.String |
toString(java.lang.String format)
Converts the value of the current
DateTime object to its equivalent
string representation using the specified format. |
java.lang.String |
toString(java.lang.String format,
java.util.Locale locale)
Converts the value of the current
DateTime object to its equivalent
string representation using the specified format and locale. |
java.lang.String |
toString(java.lang.String format,
java.util.Locale locale,
boolean excelFormat)
Converts the value of the current
DateTime object to its equivalent
string representation using the specified format and locale. |
DateTime |
toUniversalTime()
Converts the value of the current
DateTime object to Coordinated Universal Time (UTC). |
static DateTime |
utcNow()
Gets a
DateTime object that is set to the current date and time
on this computer, expressed as the Coordinated Universal Time (UTC). |
public DateTime(java.time.LocalDateTime dateTime)
DateTime
class, storing specified LocalDateTime.dateTime
- A java.time.LocalDateTime instance specifying date and time.public DateTime(java.util.Date date)
DateTime
class, representing specified Date.date
- A java.util.Date instance.public DateTime(int year, int month, int day)
DateTime
class with the specified values.year
- The year component of the new date.month
- The month component of the new date.day
- The day component of the new date.public DateTime(int year, int month, int day, int hour, int minute, int second)
DateTime
class with the specified values.year
- The year component of the new date.month
- The month component of the new date.day
- The day component of the new date.hour
- The hour component of the new date.minute
- The minute component of the new date.second
- The second component of the new date.public DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)
DateTime
class with the specified values.year
- The year component of the new date.month
- The month component of the new date.day
- The day component of the new date.hour
- The hour component of the new date.minute
- The minute component of the new date.second
- The second component of the new date.millisecond
- The millisecond component of the new date.public DateTime(long ticks)
DateTime
class with the specified number of ticks.ticks
- A date and time expressed in number of 100-nanosecond intervals.public DateTime clone()
Cloneable.clone
implementation.clone
in class java.lang.Object
DateTime
object.public int compareTo(DateTime o)
Comparable.compareTo
implementation.public boolean equals(java.lang.Object value)
Object.equals
override.equals
in class java.lang.Object
value
- The object to compare to this instance.public int hashCode()
Object.hashCode
override.hashCode
in class java.lang.Object
public java.time.LocalDateTime toJavaDateTime()
public java.util.Calendar toJavaCalendar()
public java.lang.String toString()
DateTime
object to its equivalent
string representation.toString
in class java.lang.Object
DateTime
object.public java.lang.String toString(java.lang.String format)
DateTime
object to its equivalent
string representation using the specified format.format
- A standard or custom date and time format string.DateTime
object as
specified by format.public java.lang.String toString(java.lang.String format, java.util.Locale locale)
DateTime
object to its equivalent
string representation using the specified format and locale.format
- A standard or custom date and time format string.locale
- The locale that supplies culture-specific formatting information.DateTime
object as
specified by format.public java.lang.String toString(java.lang.String format, java.util.Locale locale, boolean excelFormat)
DateTime
object to its equivalent
string representation using the specified format and locale.format
- A standard or custom date and time format string.locale
- The locale that supplies culture-specific formatting information.excelFormat
- true to accept Excel-compatible format strings, or false otherwise.DateTime
object as
specified by format.public java.lang.String toShortTimeString()
DateTime
object to its equivalent
short time string representation.DateTime
object.public java.lang.String toShortTimeString(java.util.Locale locale)
DateTime
object to its equivalent
short time string representation.locale
- The locale that supplies culture-specific formatting information.DateTime
object.public java.lang.String toLongTimeString()
DateTime
object to its equivalent
long time string representation.DateTime
object.public java.lang.String toLongTimeString(java.util.Locale locale)
DateTime
object to its equivalent
long time string representation.locale
- The locale that supplies culture-specific formatting information.DateTime
object.public java.lang.String toShortDateString()
DateTime
object to its equivalent
short date string representation.DateTime
object.public java.lang.String toShortDateString(java.util.Locale locale)
DateTime
object to its equivalent
short date string representation.locale
- The locale that supplies culture-specific formatting information.DateTime
object.public java.lang.String toLongDateString()
DateTime
object to its equivalent
long date string representation.DateTime
object.public java.lang.String toLongDateString(java.util.Locale locale)
DateTime
object to its equivalent
long date string representation.locale
- The locale that supplies culture-specific formatting information.DateTime
object.public DateTime addTicks(long value)
DateTime
that adds the specified number of
ticks to this instance.value
- A number ticks. The value parameter can be positive or negative.DateTime
whose value is the sum of the date and time represented
by this instance and the time represented by value.public DateTime addMilliseconds(double value)
DateTime
that adds the specified number of
milliseconds to this instance.value
- A number of whole and fractional milliseconds. The value parameter can be
negative or positive. Note that this value is rounded to the nearest integer.DateTime
whose value is the sum of the date and time represented
by this instance and the number of milliseconds represented by value.public DateTime addMilliseconds(long value)
DateTime
that adds the specified number of
milliseconds to this instance.value
- The number of milliseconds to add. The value parameter can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of milliseconds represented by value.public DateTime addSeconds(double value)
DateTime
that adds the specified number of
seconds to this instance.value
- A number of whole and fractional seconds. The value parameter
can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of seconds represented by value.public DateTime addSeconds(long value)
DateTime
that adds the specified number of
seconds to this instance.value
- The number of seconds to add. The value parameter can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of seconds represented by value.public DateTime addMinutes(double value)
DateTime
that adds the specified number of
minutes to this instance.value
- A number of whole and fractional minutes. The value parameter
can be negative or positive.DateTime
whose value is the sum of the date and time
represented by this instance and the number of minutes represented by value.public DateTime addMinutes(long value)
DateTime
that adds the specified number of
minutes to this instance.value
- The number of minutes to add. The value parameter can be negative or positive.DateTime
whose value is the sum of the date and time
represented by this instance and the number of minutes represented by value.public DateTime addHours(double value)
DateTime
that adds the specified number of
hours to this instance.value
- A number of whole and fractional hours. The value parameter
can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of hours represented by value.public DateTime addHours(long value)
DateTime
that adds the specified number of
hours to this instance.value
- The number of hours to add. The value parameter can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of hours represented by value.public DateTime addDays(double value)
DateTime
that adds the specified number of
days to this instance.value
- A number of days. The value parameter can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of days represented by value.public DateTime addDays(long value)
DateTime
that adds the specified number of
days to this instance.value
- The number of days to add. The value parameter can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of days represented by value.public DateTime addMonths(long value)
DateTime
that adds the specified number of
months to this instance.value
- A number of months. The months parameter can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and months.public DateTime addYears(int value)
DateTime
that adds the specified number of
years to this instance.value
- A number of years. The value parameter can be negative or positive.DateTime
whose value is the sum of the date and time represented
by this instance and the number of years represented by value.public Duration subtract(DateTime date)
public DateTime subtract(Duration duration)
public static boolean isLeapYear(int year)
year
- A 4-digit year.public DateTime toUniversalTime()
DateTime
object to Coordinated Universal Time (UTC).DateTime
object representing the UTC equivalent of the
current date and time.public DateTime toLocalTime()
DateTime
object to local time.DateTime
object representing the local time equivalent of the
current date and time.public static boolean op_Equality(DateTime d1, DateTime d2)
DateTime
are equal.public boolean isLessThan(DateTime d)
d
- A DateTime
.public boolean isLessThanOrEqual(DateTime d)
d
- A DateTime
.public static Duration op_Subtraction(DateTime d1, DateTime d2)
public static DateTime op_Addition(DateTime d, Duration t)
public static DateTime op_Subtraction(DateTime d, Duration t)
public static boolean op_Inequality(DateTime d1, DateTime d2)
DateTime
are not equal.public static DateTime now()
DateTime
object that is set to the current date and time
in the default time zone and locale.DateTime
whose value is the current local date and time.public static DateTime utcNow()
DateTime
object that is set to the current date and time
on this computer, expressed as the Coordinated Universal Time (UTC).DateTime
whose value is the current UTC date and time.public static DateTime today()
DateTime
object that represents the current date
in the default time one and locale.DateTime
set to today's date, with the time component set to 00:00:00.public static int daysInMonth(int year, int month)
year
- The year.month
- The month (a number ranging from 1 to 12).public int getWeekOfYear()
public int getYear()
public int getMonth()
public int getDay()
public int getHour()
public int getMinute()
public int getSecond()
public int getMillisecond()
public long getTicks()
public DateTime getDate()
DateTime
with the same date as this instance,
and the time value set to 12:00:00 midnight (00:00:00).public Duration getTimeOfDay()
Duration
that represents the fraction of the day that has
elapsed since midnight.public DayOfWeek getDayOfWeek()
DayOfWeek
constants.public int getDayOfYear()
public boolean isUtcTime()
public boolean isLocalTime()
public boolean isWeekend()