Java examples for java.util:Hour
hour Range
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); public static Integer hourRange(String begin, String end) { Date start = null;/*from w ww.j a va 2 s . c o m*/ Date stop = null; try { start = sdf.parse(begin); stop = sdf.parse(end); } catch (ParseException e) { e.printStackTrace(); return null; } long range = (stop.getTime() - start.getTime()) / 1000 / 60 / 60; return Integer.parseInt(String.valueOf(range)); } }