Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { private static boolean isSameAmPm(long start, long end) { Calendar starting = calendarByMillis(start); Calendar ending = calendarByMillis(end); return starting.get(Calendar.AM_PM) == ending.get(Calendar.AM_PM); } private static Calendar calendarByMillis(long millis) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(millis); return calendar; } }