java 日期范围
来源:百度知道 编辑:UC知道 时间:2024/09/28 10:20:17
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));