public class JsDate extends JavaScriptObject
Modifier | Constructor and Description |
---|---|
protected |
JsDate()
Non directly instantiable, use one of the
create() methods. |
Modifier and Type | Method and Description |
---|---|
static JsDate |
create()
Creates a new date with the current time.
|
static JsDate |
create(double milliseconds)
Creates a new date with the specified internal representation, which is the
number of milliseconds since midnight on January 1st, 1970.
|
static JsDate |
create(int year,
int month)
Creates a new date using the specified values.
|
static JsDate |
create(int year,
int month,
int dayOfMonth)
Creates a new date using the specified values.
|
static JsDate |
create(int year,
int month,
int dayOfMonth,
int hours)
Creates a new date using the specified values.
|
static JsDate |
create(int year,
int month,
int dayOfMonth,
int hours,
int minutes)
Creates a new date using the specified values.
|
static JsDate |
create(int year,
int month,
int dayOfMonth,
int hours,
int minutes,
int seconds)
Creates a new date using the specified values.
|
static JsDate |
create(int year,
int month,
int dayOfMonth,
int hours,
int minutes,
int seconds,
int millis)
Creates a new date using the specified values.
|
static JsDate |
create(java.lang.String dateString)
Creates a new date from a string to be parsed.
|
int |
getDate()
Returns the day of the month.
|
int |
getDay()
Returns the day of the week, from
0 (Sunday) to 6
Saturday. |
int |
getFullYear()
Returns the four-digit year.
|
int |
getHours()
Returns the hour, between
0 (midnight) and 23 . |
int |
getMilliseconds()
Returns the milliseconds, between
0 and 999 . |
int |
getMinutes()
Returns the minutes, between
0 and 59 . |
int |
getMonth()
Returns the month, from
0 (January) to 11
December. |
int |
getSeconds()
Returns the seconds, between
0 and 59 . |
double |
getTime()
Returns the internal millisecond representation of the date, the number of
milliseconds since midnight on January 1st, 1970.
|
int |
getTimezoneOffset()
Returns the difference, in minutes, between the local and UTC
representations of this date.
|
int |
getUTCDate()
Returns the day of the month, in UTC.
|
int |
getUTCDay()
Returns the day of the week, from
0 (Sunday) to 6
Saturday, in UTC. |
int |
getUTCFullYear()
Returns the four-digit year, in UTC.
|
int |
getUTCHours()
Returns the hour, between
0 (midnight) and 23 , in
UTC. |
int |
getUTCMilliseconds()
Returns the milliseconds, between
0 and 999 , in
UTC. |
int |
getUTCMinutes()
Returns the minutes, between
0 and 59 , in UTC. |
int |
getUTCMonth()
Returns the month, from
0 (January) to 11
December, in UTC. |
int |
getUTCSeconds()
Returns the seconds, between
0 and 59 , in UTC. |
int |
getYear()
Deprecated.
Use
getFullYear() . |
static double |
now()
Returns the numeric value corresponding to the current time -
the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
|
static double |
parse(java.lang.String dateString)
Parses a string representation of a date and time and returns the internal
millisecond representation.
|
double |
setDate(int dayOfMonth)
Sets the day of the month.
|
double |
setFullYear(int year)
Sets the year.
|
double |
setFullYear(int year,
int month)
Sets the year and month.
|
double |
setFullYear(int year,
int month,
int day)
Sets the year, month, and day.
|
double |
setHours(int hours)
Sets the hour.
|
double |
setHours(int hours,
int mins)
Sets the hour and minutes.
|
double |
setHours(int hours,
int mins,
int secs)
Sets the hour, minutes, and seconds.
|
double |
setHours(int hours,
int mins,
int secs,
int ms)
Sets the hour, minutes, seconds, and milliseconds.
|
double |
setMinutes(int minutes)
Sets the minutes.
|
double |
setMinutes(int minutes,
int seconds)
Sets the minutes and seconds.
|
double |
setMinutes(int minutes,
int seconds,
int millis)
Sets the minutes, seconds, and milliseconds.
|
double |
setMonth(int month)
Sets the month.
|
double |
setMonth(int month,
int dayOfMonth)
Sets the month and day.
|
double |
setSeconds(int seconds)
Sets the seconds.
|
double |
setSeconds(int seconds,
int millis)
Sets the seconds and milliseconds.
|
double |
setTime(double milliseconds)
Sets the internal date representation.
|
double |
setUTCDate(int dayOfMonth)
Sets the day of the month, in UTC.
|
double |
setUTCFullYear(int year)
Sets the year, in UTC.
|
double |
setUTCFullYear(int year,
int month)
Sets the year and month, in UTC.
|
double |
setUTCFullYear(int year,
int month,
int day)
Sets the year, month, and day, in UTC.
|
double |
setUTCHours(int hours)
Sets the hour, in UTC.
|
double |
setUTCHours(int hours,
int mins)
Sets the hour and minutes, in UTC.
|
double |
setUTCHours(int hours,
int mins,
int secs)
Sets the hour, minutes, and seconds, in UTC.
|
double |
setUTCHours(int hours,
int mins,
int secs,
int ms)
Sets the hour, minutes, seconds, and milliseconds, in UTC.
|
double |
setUTCMinutes(int minutes)
Sets the minutes, in UTC.
|
double |
setUTCMinutes(int minutes,
int seconds)
Sets the minutes and seconds, in UTC.
|
double |
setUTCMinutes(int minutes,
int seconds,
int millis)
Sets the minutes, seconds, and milliseconds, in UTC.
|
double |
setUTCMonth(int month)
Sets the month, in UTC.
|
double |
setUTCMonth(int month,
int dayOfMonth)
Sets the month and day, in UTC.
|
double |
setUTCSeconds(int seconds)
Sets the seconds, in UTC.
|
double |
setUTCSeconds(int seconds,
int millis)
Sets the seconds and milliseconds, in UTC.
|
double |
setYear(int year)
Deprecated.
Use
setFullYear(int) . |
java.lang.String |
toDateString()
Returns a date string in the local time zone.
|
java.lang.String |
toGMTString()
Deprecated.
Use
toUTCString() . |
java.lang.String |
toLocaleDateString()
Returns a date string in the local time zone according to local formatting
conventions.
|
java.lang.String |
toLocaleString()
Returns a date and time string in the local time zone according to local
formatting conventions.
|
java.lang.String |
toLocaleTimeString()
Returns a time string in the local time zone according to local formatting
conventions.
|
java.lang.String |
toTimeString()
Returns a time string in the local time zone.
|
java.lang.String |
toUTCString()
Returns a date and time string in UTC.
|
static double |
UTC(int year,
int month,
int dayOfMonth,
int hours,
int minutes,
int seconds,
int millis)
Returns the internal millisecond representation of the specified UTC date
and time.
|
double |
valueOf()
Returns the millisecond representation, as
getTime() . |
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
protected JsDate()
create()
methods.public static JsDate create()
public static JsDate create(double milliseconds)
getTime()
.public static JsDate create(int year, int month)
public static JsDate create(int year, int month, int dayOfMonth)
public static JsDate create(int year, int month, int dayOfMonth, int hours)
public static JsDate create(int year, int month, int dayOfMonth, int hours, int minutes)
public static JsDate create(int year, int month, int dayOfMonth, int hours, int minutes, int seconds)
public static JsDate create(int year, int month, int dayOfMonth, int hours, int minutes, int seconds, int millis)
public static JsDate create(java.lang.String dateString)
public static double now()
public static double parse(java.lang.String dateString)
NaN
. Use Double.isNaN(double)
to check
the result.public static double UTC(int year, int month, int dayOfMonth, int hours, int minutes, int seconds, int millis)
public final int getDate()
public final int getDay()
0
(Sunday) to 6
Saturday.public final int getFullYear()
public final int getHours()
0
(midnight) and 23
.public final int getMilliseconds()
0
and 999
.public final int getMinutes()
0
and 59
.public final int getMonth()
0
(January) to 11
December.public final int getSeconds()
0
and 59
.public final double getTime()
getTime()
.public final int getTimezoneOffset()
public final int getUTCDate()
public final int getUTCDay()
0
(Sunday) to 6
Saturday, in UTC.public final int getUTCFullYear()
public final int getUTCHours()
0
(midnight) and 23
, in
UTC.public final int getUTCMilliseconds()
0
and 999
, in
UTC.public final int getUTCMinutes()
0
and 59
, in UTC.public final int getUTCMonth()
0
(January) to 11
December, in UTC.public final int getUTCSeconds()
0
and 59
, in UTC.@Deprecated public final int getYear()
getFullYear()
.public final double setDate(int dayOfMonth)
public final double setFullYear(int year)
public final double setFullYear(int year, int month)
public final double setFullYear(int year, int month, int day)
public final double setHours(int hours)
public final double setHours(int hours, int mins)
public final double setHours(int hours, int mins, int secs)
public final double setHours(int hours, int mins, int secs, int ms)
public final double setMinutes(int minutes)
public final double setMinutes(int minutes, int seconds)
public final double setMinutes(int minutes, int seconds, int millis)
public final double setMonth(int month)
public final double setMonth(int month, int dayOfMonth)
public final double setSeconds(int seconds)
public final double setSeconds(int seconds, int millis)
public final double setTime(double milliseconds)
milliseconds
argument.public final double setUTCDate(int dayOfMonth)
public final double setUTCFullYear(int year)
public final double setUTCFullYear(int year, int month)
public final double setUTCFullYear(int year, int month, int day)
public final double setUTCHours(int hours)
public final double setUTCHours(int hours, int mins)
public final double setUTCHours(int hours, int mins, int secs)
public final double setUTCHours(int hours, int mins, int secs, int ms)
public final double setUTCMinutes(int minutes)
public final double setUTCMinutes(int minutes, int seconds)
public final double setUTCMinutes(int minutes, int seconds, int millis)
public final double setUTCMonth(int month)
public final double setUTCMonth(int month, int dayOfMonth)
public final double setUTCSeconds(int seconds)
public final double setUTCSeconds(int seconds, int millis)
@Deprecated public final double setYear(int year)
setFullYear(int)
.public final java.lang.String toDateString()
@Deprecated public final java.lang.String toGMTString()
toUTCString()
.public final java.lang.String toLocaleDateString()
public final java.lang.String toLocaleString()
public final java.lang.String toLocaleTimeString()
public final java.lang.String toTimeString()
public final java.lang.String toUTCString()
public final double valueOf()
getTime()
.