This content has been marked as final. Show 2 replies
Welcome to the forum!
The book that I am reading says, Date class represents a long int value since Jan 01 , 1970.
I created a Date class as follows
long st = 2000L;
System.out.println("New time is ="+d.toString());
When the above code in run, it prints the date as follows.
New time is =Wed Dec 31 16:00:02 PST 1969
Any idea why the date printed in before 1970 ? I was expecting the date displayed to be some value greater than 01, Jan , 1970.
Because of the way that the setTime method is defined. What timezone are you using?
public void setTime(long date)Sets an existing Date object using the given milliseconds time value. If the given milliseconds value contains time information, the driver will set the time components to the time in the default time zone (the time zone of the Java virtual machine running the application) that corresponds to zero GMT.