Package com.google.gwt.core.client
Class JsDate
java.lang.Object
com.google.gwt.core.client.JavaScriptObject
com.google.gwt.core.client.JsDate
A simple wrapper around a native JS Date object.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsDatecreate()Creates a new date with the current time.static JsDatecreate(double milliseconds) Creates a new date with the specified internal representation, which is the number of milliseconds since midnight on January 1st, 1970.static JsDatecreate(int year, int month) Creates a new date using the specified values.static JsDatecreate(int year, int month, int dayOfMonth) Creates a new date using the specified values.static JsDatecreate(int year, int month, int dayOfMonth, int hours) Creates a new date using the specified values.static JsDatecreate(int year, int month, int dayOfMonth, int hours, int minutes) Creates a new date using the specified values.static JsDatecreate(int year, int month, int dayOfMonth, int hours, int minutes, int seconds) Creates a new date using the specified values.static JsDatecreate(int year, int month, int dayOfMonth, int hours, int minutes, int seconds, int millis) Creates a new date using the specified values.static JsDateCreates a new date from a string to be parsed.final intgetDate()Returns the day of the month.final intgetDay()Returns the day of the week, from0(Sunday) to6Saturday.final intReturns the four-digit year.final intgetHours()Returns the hour, between0(midnight) and23.final intReturns the milliseconds, between0and999.final intReturns the minutes, between0and59.final intgetMonth()Returns the month, from0(January) to11December.final intReturns the seconds, between0and59.final doublegetTime()Returns the internal millisecond representation of the date, the number of milliseconds since midnight on January 1st, 1970.final intReturns the difference, in minutes, between the local and UTC representations of this date.final intReturns the day of the month, in UTC.final intReturns the day of the week, from0(Sunday) to6Saturday, in UTC.final intReturns the four-digit year, in UTC.final intReturns the hour, between0(midnight) and23, in UTC.final intReturns the milliseconds, between0and999, in UTC.final intReturns the minutes, between0and59, in UTC.final intReturns the month, from0(January) to11December, in UTC.final intReturns the seconds, between0and59, in UTC.final intgetYear()Deprecated.static doublenow()Returns the numeric value corresponding to the current time - the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.static doubleParses a string representation of a date and time and returns the internal millisecond representation.final doublesetDate(int dayOfMonth) Sets the day of the month.final doublesetFullYear(int year) Sets the year.final doublesetFullYear(int year, int month) Sets the year and month.final doublesetFullYear(int year, int month, int day) Sets the year, month, and day.final doublesetHours(int hours) Sets the hour.final doublesetHours(int hours, int mins) Sets the hour and minutes.final doublesetHours(int hours, int mins, int secs) Sets the hour, minutes, and seconds.final doublesetHours(int hours, int mins, int secs, int ms) Sets the hour, minutes, seconds, and milliseconds.final doublesetMinutes(int minutes) Sets the minutes.final doublesetMinutes(int minutes, int seconds) Sets the minutes and seconds.final doublesetMinutes(int minutes, int seconds, int millis) Sets the minutes, seconds, and milliseconds.final doublesetMonth(int month) Sets the month.final doublesetMonth(int month, int dayOfMonth) Sets the month and day.final doublesetSeconds(int seconds) Sets the seconds.final doublesetSeconds(int seconds, int millis) Sets the seconds and milliseconds.final doublesetTime(double milliseconds) Sets the internal date representation.final doublesetUTCDate(int dayOfMonth) Sets the day of the month, in UTC.final doublesetUTCFullYear(int year) Sets the year, in UTC.final doublesetUTCFullYear(int year, int month) Sets the year and month, in UTC.final doublesetUTCFullYear(int year, int month, int day) Sets the year, month, and day, in UTC.final doublesetUTCHours(int hours) Sets the hour, in UTC.final doublesetUTCHours(int hours, int mins) Sets the hour and minutes, in UTC.final doublesetUTCHours(int hours, int mins, int secs) Sets the hour, minutes, and seconds, in UTC.final doublesetUTCHours(int hours, int mins, int secs, int ms) Sets the hour, minutes, seconds, and milliseconds, in UTC.final doublesetUTCMinutes(int minutes) Sets the minutes, in UTC.final doublesetUTCMinutes(int minutes, int seconds) Sets the minutes and seconds, in UTC.final doublesetUTCMinutes(int minutes, int seconds, int millis) Sets the minutes, seconds, and milliseconds, in UTC.final doublesetUTCMonth(int month) Sets the month, in UTC.final doublesetUTCMonth(int month, int dayOfMonth) Sets the month and day, in UTC.final doublesetUTCSeconds(int seconds) Sets the seconds, in UTC.final doublesetUTCSeconds(int seconds, int millis) Sets the seconds and milliseconds, in UTC.final doublesetYear(int year) Deprecated.UsesetFullYear(int).final StringReturns a date string in the local time zone.final StringDeprecated.UsetoUTCString().final StringReturns a date string in the local time zone according to local formatting conventions.final StringReturns a date and time string in the local time zone according to local formatting conventions.final StringReturns a time string in the local time zone according to local formatting conventions.final StringReturns a time string in the local time zone.final StringReturns a date and time string in UTC.static doubleUTC(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.final doublevalueOf()Returns the millisecond representation, asgetTime().Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
-
Constructor Details
-
JsDate
protected JsDate()Non directly instantiable, use one of thecreate()methods.
-
-
Method Details
-
create
Creates a new date with the current time. -
create
Creates a new date with the specified internal representation, which is the number of milliseconds since midnight on January 1st, 1970. This is the same representation returned bygetTime(). -
create
Creates a new date using the specified values. -
create
Creates a new date using the specified values. -
create
Creates a new date using the specified values. -
create
Creates a new date using the specified values. -
create
public static JsDate create(int year, int month, int dayOfMonth, int hours, int minutes, int seconds) Creates a new date using the specified values. -
create
public 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. -
create
Creates a new date from a string to be parsed. -
now
public 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. -
parse
Parses a string representation of a date and time and returns the internal millisecond representation. If the string cannot be parsed, the returned value will beNaN. UseDouble.isNaN(double)to check the result. -
UTC
public 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. -
getDate
public final int getDate()Returns the day of the month. -
getDay
public final int getDay()Returns the day of the week, from0(Sunday) to6Saturday. -
getFullYear
public final int getFullYear()Returns the four-digit year. -
getHours
public final int getHours()Returns the hour, between0(midnight) and23. -
getMilliseconds
public final int getMilliseconds()Returns the milliseconds, between0and999. -
getMinutes
public final int getMinutes()Returns the minutes, between0and59. -
getMonth
public final int getMonth()Returns the month, from0(January) to11December. -
getSeconds
public final int getSeconds()Returns the seconds, between0and59. -
getTime
public final double getTime()Returns the internal millisecond representation of the date, the number of milliseconds since midnight on January 1st, 1970. This is the same representation returned bygetTime(). -
getTimezoneOffset
public final int getTimezoneOffset()Returns the difference, in minutes, between the local and UTC representations of this date. The value returned is affected by whether or not daylight savings time would be in effect on specified date. -
getUTCDate
public final int getUTCDate()Returns the day of the month, in UTC. -
getUTCDay
public final int getUTCDay()Returns the day of the week, from0(Sunday) to6Saturday, in UTC. -
getUTCFullYear
public final int getUTCFullYear()Returns the four-digit year, in UTC. -
getUTCHours
public final int getUTCHours()Returns the hour, between0(midnight) and23, in UTC. -
getUTCMilliseconds
public final int getUTCMilliseconds()Returns the milliseconds, between0and999, in UTC. -
getUTCMinutes
public final int getUTCMinutes()Returns the minutes, between0and59, in UTC. -
getUTCMonth
public final int getUTCMonth()Returns the month, from0(January) to11December, in UTC. -
getUTCSeconds
public final int getUTCSeconds()Returns the seconds, between0and59, in UTC. -
getYear
Deprecated.UsegetFullYear().Returns the year minus 1900. -
setDate
public final double setDate(int dayOfMonth) Sets the day of the month. Returns the millisecond representation of the adjusted date. -
setFullYear
public final double setFullYear(int year) Sets the year. Returns the millisecond representation of the adjusted date. -
setFullYear
public final double setFullYear(int year, int month) Sets the year and month. Returns the millisecond representation of the adjusted date. -
setFullYear
public final double setFullYear(int year, int month, int day) Sets the year, month, and day. Returns the millisecond representation of the adjusted date. -
setHours
public final double setHours(int hours) Sets the hour. Returns the millisecond representation of the adjusted date. -
setHours
public final double setHours(int hours, int mins) Sets the hour and minutes. Returns the millisecond representation of the adjusted date. -
setHours
public final double setHours(int hours, int mins, int secs) Sets the hour, minutes, and seconds. Returns the millisecond representation of the adjusted date. -
setHours
public final double setHours(int hours, int mins, int secs, int ms) Sets the hour, minutes, seconds, and milliseconds. Returns the millisecond representation of the adjusted date. -
setMinutes
public final double setMinutes(int minutes) Sets the minutes. Returns the millisecond representation of the adjusted date. -
setMinutes
public final double setMinutes(int minutes, int seconds) Sets the minutes and seconds. Returns the millisecond representation of the adjusted date. -
setMinutes
public final double setMinutes(int minutes, int seconds, int millis) Sets the minutes, seconds, and milliseconds. Returns the millisecond representation of the adjusted date. -
setMonth
public final double setMonth(int month) Sets the month. Returns the millisecond representation of the adjusted date. -
setMonth
public final double setMonth(int month, int dayOfMonth) Sets the month and day. Returns the millisecond representation of the adjusted date. -
setSeconds
public final double setSeconds(int seconds) Sets the seconds. Returns the millisecond representation of the adjusted date. -
setSeconds
public final double setSeconds(int seconds, int millis) Sets the seconds and milliseconds. Returns the millisecond representation of the adjusted date. -
setTime
public final double setTime(double milliseconds) Sets the internal date representation. Returns themillisecondsargument. -
setUTCDate
public final double setUTCDate(int dayOfMonth) Sets the day of the month, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCFullYear
public final double setUTCFullYear(int year) Sets the year, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCFullYear
public final double setUTCFullYear(int year, int month) Sets the year and month, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCFullYear
public final double setUTCFullYear(int year, int month, int day) Sets the year, month, and day, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCHours
public final double setUTCHours(int hours) Sets the hour, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCHours
public final double setUTCHours(int hours, int mins) Sets the hour and minutes, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCHours
public final double setUTCHours(int hours, int mins, int secs) Sets the hour, minutes, and seconds, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCHours
public final double setUTCHours(int hours, int mins, int secs, int ms) Sets the hour, minutes, seconds, and milliseconds, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCMinutes
public final double setUTCMinutes(int minutes) Sets the minutes, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCMinutes
public final double setUTCMinutes(int minutes, int seconds) Sets the minutes and seconds, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCMinutes
public final double setUTCMinutes(int minutes, int seconds, int millis) Sets the minutes, seconds, and milliseconds, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCMonth
public final double setUTCMonth(int month) Sets the month, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCMonth
public final double setUTCMonth(int month, int dayOfMonth) Sets the month and day, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCSeconds
public final double setUTCSeconds(int seconds) Sets the seconds, in UTC. Returns the millisecond representation of the adjusted date. -
setUTCSeconds
public final double setUTCSeconds(int seconds, int millis) Sets the seconds and milliseconds, in UTC. Returns the millisecond representation of the adjusted date. -
setYear
Deprecated.UsesetFullYear(int).Sets a two-digit year. -
toDateString
Returns a date string in the local time zone. -
toGMTString
Deprecated.UsetoUTCString().Returns a date and time string in GMT. -
toLocaleDateString
Returns a date string in the local time zone according to local formatting conventions. -
toLocaleString
Returns a date and time string in the local time zone according to local formatting conventions. -
toLocaleTimeString
Returns a time string in the local time zone according to local formatting conventions. -
toTimeString
Returns a time string in the local time zone. -
toUTCString
Returns a date and time string in UTC. -
valueOf
public final double valueOf()Returns the millisecond representation, asgetTime().
-
getFullYear().