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