为什么java.sql.Time对象在一年内给出不同的时间间隔?

为什么java.sql.Time对象在一年内给出不同的时间间隔?,java,date,time,Java,Date,Time,对于java.sql.Time对象如何计算时间,我有点困惑 我试着每天在某个特定的时间设置一个计时器。然而,在计算时间时,为了设置闹钟,我似乎提前了一个小时设置闹钟 但这是494天前开始的(当前日期为2013年7月17日)。如果你回到更远的地方(比如1000天前),它也会发生,我猜它每几百天循环+1小时和+0小时 我可以从输入时间中减去一个小时,但我想知道为什么会发生这种情况 private static long oneDayInMill = timeToMill(24, 0); priva

对于java.sql.Time对象如何计算时间,我有点困惑

我试着每天在某个特定的时间设置一个计时器。然而,在计算时间时,为了设置闹钟,我似乎提前了一个小时设置闹钟

但这是494天前开始的(当前日期为2013年7月17日)。如果你回到更远的地方(比如1000天前),它也会发生,我猜它每几百天循环+1小时和+0小时

我可以从输入时间中减去一个小时,但我想知道为什么会发生这种情况

private static long oneDayInMill = timeToMill(24, 0); 
private static long reminderTime = timeToMill(13 + 6, 25); //military time; it starts at 18, not 0 for some reason
private static long currentTimeInMill = System.currentTimeMillis() % oneDayInMill;
private static long currentDayInMill = System.currentTimeMillis() - currentTimeInMill;

    System.out.println(new Time(currentDayInMill - (oneDayInMill*495)+ reminderTime).toString());
// This displays as 13:25:00 (as  I expect)
    System.out.println(new Time(currentDayInMill - (oneDayInMill*494)+ reminderTime).toString());
// This displays as 14:25:00 (not as I would expect)

public static long timeToMill(int hr, int min){
        //out of bounds
        return (hr*60*60*1000 + min*60*1000);
    }
我认为我的计算机使用的时区是CST(这是我输出Date java.util.Date对象时的输出)


对不起,如果我的问题有点让人困惑的话

吉特曼和戴夫·巴特利特是对的。如果我在495天前打印出日期对象,我将收到

Sat Mar 10 18:00:00 CST 2012
如果我在494天前打印出日期对象,我将收到:

Sun Mar 11 19:00:00 CDT 2012

一小时差=可疑夏令时/夏令时。您的时区是什么?您的意思是
java.sql.time
?使用SimpleTimeFormat打印整个时间规格--年、月、日、时区、夏令时、沙鼠数量等等。@rgetman是正确的。在将494/495值增加1的循环中运行此代码,您将看到两个打印输出在夏令时变化。