0
我堅持在Android上運行這個例子:日期時間不一致
SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy kkmm");
sdf.setTimeZone(TimeZone.getTimeZone(Time.TIMEZONE_UTC));
Date scheduledDateTime = sdf.parse(sms.getScheduledDateTime());
Log.i(TAG, "scheduledDateTime is : " + scheduledDateTime); // scheduledDateTime is : Fri Jan 06 23:58:00 HNEC 2012
Log.i(TAG, "scheduledDateTime milli : " + scheduledDateTime.getTime()); // scheduledDateTime milli : 1325890680000
Calendar calendar = Calendar.getInstance();
Calendar defaultTZCalendar = Calendar.getInstance(TimeZone.getDefault());
Calendar utcTZCalendar = Calendar.getInstance(TimeZone.getTimeZone(Time.TIMEZONE_UTC));
calendar.setTime(scheduledDateTime);
defaultTZCalendar.setTime(scheduledDateTime);
utcTZCalendar.setTime(scheduledDateTime);
Log.i(TAG, "calendar : " + calendar.getTimeInMillis()); // calendar : 1325890680000
Log.i(TAG, "defaultTZCalendar : " + defaultTZCalendar.getTimeInMillis()); // defaultTZCalendar : 1325890680000
Log.i(TAG, "utcTZCalendar : " + utcTZCalendar.getTimeInMillis()); // utcTZCalendar : 1325890680000
現在看看這個:
final long currentTimeMillis = System.currentTimeMillis();
Log.i(TAG, " currentTimeMillis is " + currentTimeMillis); // currentTimeMillis is 1341608182431
Date d = new Date(currentTimeMillis);
Log.i(TAG, " currentTimeMillis is " + d + " ::: d.getTime() = " + d.getTime()); // currentTimeMillis is Fri Jul 06 22:56:22 HAEC 2012 ::: d.getTime() = 1341608182431
怎麼可能有15713902431兩者之間的這種差異日期看起來相同:Fri Jan 06 23:58:00 HNEC 2012 and Fri Jul 06 22:56:22 HAEC 2012
BTW,
HNEC是(法語)普通中央EUROP時間
HAEC是先進的中央EUROP時間(即DST)
感謝
你先生是非常親切,我很愚蠢。由於S.O.會在幾分鐘內接受你的答案。謝謝 – redochka 2012-07-06 21:44:31