W
www
Hi,
I found that Java's time related classes are so hard to use. For example:
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(0); //set cal at January 1st 00:00:00, 1970
To TRUELY understand the above code and use it correctly, I need to know
that BY DEFAULT, GregorianCalendar set its time zone from my computer
location. Since I am in the east coast of US, the time zone of the
object cal is set as East Daylight Saving Time. So for another computer
located in California, running the above two lines of code, cal time is
different. Ok, I try to remember that.
Now:
Date date = new Date();
date.setTime(long time); //takes a long argument
By default, date time zone is UTC (Universal time, greenwich time -- GMT).
Am I using them in-correctly or they are really error-prone?
Thank you for your feedbacks.
I found that Java's time related classes are so hard to use. For example:
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(0); //set cal at January 1st 00:00:00, 1970
To TRUELY understand the above code and use it correctly, I need to know
that BY DEFAULT, GregorianCalendar set its time zone from my computer
location. Since I am in the east coast of US, the time zone of the
object cal is set as East Daylight Saving Time. So for another computer
located in California, running the above two lines of code, cal time is
different. Ok, I try to remember that.
Now:
Date date = new Date();
date.setTime(long time); //takes a long argument
By default, date time zone is UTC (Universal time, greenwich time -- GMT).
Am I using them in-correctly or they are really error-prone?
Thank you for your feedbacks.