Here you can find the source of sameMonth(Date date1, Date date2)
public static boolean sameMonth(Date date1, Date date2)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Oobium, Inc.//w ww .ja va2 s . com * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Jeremy Dowdall <jeremy@oobium.com> - initial API and implementation ******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { public static boolean sameMonth(Date date1, Date date2) { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c1.setTime(date1); c2.setTime(date2); return c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR) && c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH); } }