The date issue occurs during eclipse programming as follows.
1. Use settime (date) to assign values to the calendar:
When you assign a value to the calendar using the following method, the result is: "Cal. gettime (). tostring ();" = "Thu Jan 01 08:01:00 CST 1970 ".
Calendar Cal = calendar. getinstance (timezone. gettimezone ("GMT"); simpledateformat sdateformat = new simpledateformat ("yyyy-mm-dd hh: mm: SS"); Date = sdateformat. parse ("08:01:00"); Cal. settime (date );
IfCodeChanged:
Calendar Cal = calendar. getinstance (timezone. gettimezone ("GMT + 8 "));
The result is still: "Cal. gettime (). tostring (); "=" Thu Jan 01 08:01:00 CST 1970 ". (the time zone has changed. Why is the gettime () result the same ?)
2. assign values to the calendar using set (INT, Int, INT:
When you assign a value to the calendar using the following method, the result is "Cal. gettime (). tostring (); "=" Thu Jan 01 16:01:00 CST 1970 ". (the time zone is set to Greenwich mean time, so the display time obtained by gettime is based on the Greenwich Mean Time plus 8 hours, which is changed to the standard Chinese time .)
Calendar Cal = calendar. getinstance (timezone. gettimezone ("GMT"); Cal. Set (, 0 );
If you change the first line of code:
Calendar Cal = calendar. getinstance (timezone. gettimezone ("GMT + 8 "));
The result is: "Cal. gettime (). tostring (); "=" Thu Jan 01 08:01:00 CST 1970 ". (set the time zone to the China time zone, and gettime () gets the same time as the set time .)
Question:
Why do the results of setting timezone to GMT, GMT + 8, or other, Cal. gettime () are the same when you use calendar. settime (date? The result of using calendar. Set (INT, Int, INT) and gettime () is reasonable.