Java 时间范围 Util

 import java.util.Date; public class TimeSpan { public final static TimeSpan ZERO = new TimeSpan(0); private long _totalMilliSeconds = 0; public TimeSpan(long totalMilliSeconds) { _totalMilliSeconds = totalMilliSeconds; } public TimeSpan(Date afterDate, Date beforeDate) { this(afterDate.getTime() - beforeDate.getTime()); } public long getMilliSeconds() { return _totalMilliSeconds; } public long getSeconds() { return Math.round(_totalMilliSeconds/1000); } public long getMinutes() { return Math.round(_totalMilliSeconds/(1000*60)); } public long getHours() { return Math.round(_totalMilliSeconds/(1000*60*60)); } }

你可能感兴趣的:(Java)