1. 程式人生 > >獲取兩個Date型別的天數差,時差,分差

獲取兩個Date型別的天數差,時差,分差

public static int getDateInterValDay(Date begin,Date end){
return (int) ((end.getTime() - begin.getTime()) / (24 * 60 * 60 * 1000));
}
public static int getDateInterValHour(Date begin,Date end){
return (int) ((end.getTime() - begin.getTime()) / (60 * 60 * 1000));
}
public static int getDateInterValSecond(Date begin,Date end){
return (int) ((end.getTime() - begin.getTime()) / (60 * 1000));
}