public class DateTest {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.set(Calendar.YEAR, 1900);
calendar.set(Calendar.HOUR, 7);
for (int i = 420; i < 1440; i++) {
Date date = calendar.getTime();
System.out.println(date);
System.out.println(date.getTime());
calendar.add(Calendar.MINUTE, 1);
}
}
}
如果執行這段代碼會發現結果是CST格式,7:59分之後時間跳躍了5:52。數據庫中我有個字段是time類型,經過blazeds和flex傳遞後,數據庫中的8:00,在客戶端顯示不正確,因此必須使用如下代碼,精確到分鐘
if (time >= -2208988740000) {
date.setTime(time + 352000);
}