Java examples for java.util:Day
is Same Day
//package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { Calendar fromCalendar = Calendar.getInstance(); Calendar toCalendar = Calendar.getInstance(); System.out.println(isSameDay(fromCalendar, toCalendar)); }/*w w w .j av a 2s . co m*/ public static boolean isSameDay(Calendar fromCalendar, Calendar toCalendar) { if (fromCalendar == null || toCalendar == null) { return false; } return fromCalendar.get(Calendar.YEAR) == toCalendar .get(Calendar.YEAR) && fromCalendar.get(Calendar.MONTH) == toCalendar .get(Calendar.MONTH) && fromCalendar.get(Calendar.DAY_OF_MONTH) == toCalendar .get(Calendar.DAY_OF_MONTH); } }