哦,谢谢,我已经知道了,下面就是我实现的方法:
GregorianCalendar grcEmployee = new GregorianCalendar();
GregorianCalendar grcSystem = new GregorianCalendar();
grcEmployee.setTime(employee.getEmployDate());
int x = 0;
while((grcEmployee.YEAR != grcSystem.YEAR) && (grcEmployee.MONTH != grcSystem.MONTH))
{
x++;
grcEmployee.add(grcEmployee.MONTH,x);
}
Integer serviceLength = new Integer(x);
GregorianCalendar grcEmployee = new GregorianCalendar();
GregorianCalendar grcSystem = new GregorianCalendar();
grcEmployee.setTime(employee.getEmployDate());
int x = 0;
while((grcEmployee.YEAR != grcSystem.YEAR) && (grcEmployee.MONTH != grcSystem.MONTH))
{
x++;
grcEmployee.add(grcEmployee.MONTH,x);
}
Integer serviceLength = new Integer(x);
Timestamp a,b;
.............
long i=a.getTime-b.getTime;
//相差时间:
天:i/(3600*24*1000)
小时:i/(3600*1000)
分钟:i/(60*1000)
秒:i