1
我有這樣的代碼:日期差異包括時區偏移量,怎麼回事?
Date now = new Date();
// the string is in UTC format, so a UTC date must be constructed, I don't know if that happens in this format
Date measure = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(utcDateTime);
long diff = now.getTime() - measure.getTime();
if (diff < 1000* 60 * 15) {
// measure is less then 15 minutes recent
do some work
}
當我得到的差異,它包括時區。我知道內部的Date對象是UTC。
那麼這裏有什麼問題?
謝謝,我會記住約達時間,雖然我不知道是否可用於Java 1.5和Android。 – Pentium10 2010-06-29 10:46:39