Code example for TimeUnit

Methods: toHours

0
	 * @param millis 
	 * @return byte[] of length 4 
	 */ 
	public static byte[] toDayDateHourColumn(long millis) {
 
		int d = Integer.MAX_VALUE - (int) TimeUnit.MILLISECONDS.toHours(millis);
 
		return Bytes.toBytes(d);
	} 
 
	/** 
	 * Convert the date column for hours into a milliseconds time stamp. 
	 *  
	 * @param dateColumn 
	 * @return long 
	 */ 
	public static long readDateHours(byte[] dateColumn) {
		int d = Bytes.readInt(dateColumn, 0);
 
		return TimeUnit.HOURS.toMillis((Integer.MAX_VALUE - d));
	}