Java-时间范围-Util
目录
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/(100060)); } public long getHours() { return Math.round(_totalMilliSeconds/(100060*60)); } }