Here you can find the source of getHourInFloat(Date date)
public static float getHourInFloat(Date date)
import org.apache.commons.lang3.time.DateUtils; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TreeSet; public class Main{ /**//from w ww.j a va2 s . c om * Converts "2013-09-08 15:30" to 15.5 * * @return hour in float */ public static float getHourInFloat(Date date) { final long hours = DateUtils.getFragmentInHours(date, Calendar.DAY_OF_MONTH); final long minutes = DateUtils.getFragmentInMinutes(date, Calendar.HOUR_OF_DAY); return hours + (minutes / 60.f); } }