Java examples for java.util:Month
is Same Month
//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(isSameMonth(fromCalendar, toCalendar)); }/*from w w w . j a v a2 s .com*/ public static boolean isSameMonth(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); } }