Java Reference
In-Depth Information
> diwali.setFullYear(2015);
<< 1447200000000
Note that the values returned by these functions is the timestamp representing the number
of milliseconds since the Epoch. To see the actual date, we need to use the
toString()
mehtod:
> diwali.toString();
<< "Wed Nov 11 2015 00:00:00 GMT+0000 (GMT)"
There are also
setHours()
,
setUTCHours()
,
setMinutes()
,
setUTCMinutes()
,
setSeconds()
,
setUTCSeconds
,
setMilliseconds()
and
setUTCMilliseconds()
methods that can be used to edit the time portion of a
Date
object.
Alternatively, if you know the date as a timestamp, you can use the
setTime()
method:
> diwali.setTime(1447200000000);
<< 1447200000000
