在java里,时间实际上是用一个long表示的(8 bytes = 64 bits)。Date类的 getTime()方法:public long getTime()Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. Returns:
the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.

解决方案 »

  1.   

    问题解决了
    我用了以下的方法
    Calendar date = Calendar.getInstance();
       int currentHour=date.get(Calendar.HOUR_OF_DAY );//当前时间
       int currentMinute=date.get(Calendar.MINUTE);
       int currentSecond=date.get(Calendar.SECOND);
       currentHour=(currentHour * 3600 + currentMinute*60 + currentSecond/60)
      

  2.   

    currentHour=(currentHour * 3600 + currentMinute*60 + currentSecond/60)
    ----------------------
    若转换位 秒,currentSecond 除以60就不对了。
    而且,不如这个省事:Calendar date = Calendar.getInstance();
    int currentTime  = date.getTime().getTime()/1000; // 毫秒数 转换位 秒数
      

  3.   

    哦,不好意思,int currentTime  = date.getTime().getTime()/1000; 和你的要求不符,还是按你的算法吧。