随笔 - 64  文章 - 9  trackbacks - 0
<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(6)

我参与的团队

随笔分类(88)

随笔档案(92)

文章分类(142)

文章档案(182)

天基成员

学习园

我的海角

搜索

  •  

积分与排名

  • 积分 - 180563
  • 排名 - 318

最新评论

package lab.sodino.clock;
public class ClockTime
 { public static long MSEL_PER_SECOND = 1000;
  public static long MSEL_PER_MINUTE = 60 * 1000;
  public static long MSEL_PER_HOUR = 60 * MSEL_PER_MINUTE;
  public static long MSEL_PER_DAY = 24 * MSEL_PER_HOUR;
  public static long MSEL_PER_YEAR = MSEL_PER_DAY * 365;
  private long hour;
  private long minute;
  private long second;
  private long msel;
         public ClockTime()
   { }

  public void update(long currentMsel, long diff)
   { long residualDayMsel = (currentMsel + diff) % MSEL_PER_DAY;
  // System.out.println(residualDayMsel);
  long hourNum = residualDayMsel / MSEL_PER_HOUR;
  hour = hourNum;
  long residualHourMsel = currentMsel % MSEL_PER_HOUR;
  long minuteNum = residualHourMsel / MSEL_PER_MINUTE;
  minute = minuteNum;
         long residualMinMsel = currentMsel % MSEL_PER_MINUTE;
  long secondNum = residualMinMsel / MSEL_PER_SECOND;
  second = secondNum;
  long residualSecMsel = currentMsel % MSEL_PER_SECOND;
  msel = residualSecMsel; // System.out.println(hour + " hour " + minute + " minute " + second // + " second");
  }

  public long getHour()
  { return hour; }

  public long getMinute()
  { return minute; }

  public long getSecond()
  { return second; }

  public long getMsel() { return msel; }
 }

posted on 2010-03-19 23:18 鹏凌 阅读(225) 评论(0)  编辑  收藏 所属分类: Java --j2ee

只有注册用户登录后才能发表评论。


网站导航: