
Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
Syntax
public void setTime(long time)
Parameters
time − the number of milliseconds.
Return Value
None
Example
Following is an example of the usage of this method −
class Example {
static void main(String[] args) {
Date olddate = new Date("05/11/2015");
Date newdate = new Date("05/12/2015");
Date latestdate = new Date();
olddate.setTime(10000);
newdate.setTime(10000);
latestdate.setTime(10000);
System.out.println(olddate.toString());
System.out.println(newdate.toString());
System.out.println(latestdate.toString());
}
}
When we run the above program, we will get the following result −
Thu Jan 01 04:00:10 GST 1970 Thu Jan 01 04:00:10 GST 1970 Thu Jan 01 04:00:10 GST 1970
Previous Page:-Click Here