Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static boolean isSameDayHour(Calendar cal1, Calendar cal2) { return (isSameDay(cal1, cal2) && (cal1.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY))); } public static boolean isSameDay(String s1, String s2) { if (s1 == null || s2 == null) return false; Calendar c1 = Calendar.getInstance(); c1.setTime(new Date(Long.parseLong(s1))); Calendar c2 = Calendar.getInstance(); c2.setTime(new Date(Long.parseLong(s2))); return isSameDay(c1, c2); } public static boolean isSameDay(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) { throw new IllegalArgumentException("The date must not be null"); } return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); } }