Code example for TimeUnit

Methods: toHours

0
 
				return  TimeUnit.MILLISECONDS.toMinutes(dateOne.getTime() - dateTwo.getTime());
 
			}else if(type.equals(DateComapareType.HOURS)){
 
				return  TimeUnit.MILLISECONDS.toHours(dateOne.getTime() - dateTwo.getTime());
 
			}else if(type.equals(DateComapareType.DAY)){
 
				return  TimeUnit.MILLISECONDS.toDays(dateOne.getTime() - dateTwo.getTime());
 
			}else if(type.equals(DateComapareType.WEEK)){
 
				long day = TimeUnit.MILLISECONDS.toDays(dateOne.getTime() - dateTwo.getTime());
				return day/7;
 
			}else{ 
				return (Long) null;
			} 
	}