Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static boolean isDateInCurrentMonth(long date) { return isDatesInSameMonth(getCurrentCalendar().getTimeInMillis(), getCalendarWithTime(date).getTimeInMillis()); } public static boolean isDatesInSameMonth(long lhs, long rhs) { Calendar lhsCalendar = getCalendarWithTime(lhs); int lhsMonth = lhsCalendar.get(Calendar.MONTH); int lhsYear = lhsCalendar.get(Calendar.YEAR); Calendar rhsCalendar = getCalendarWithTime(rhs); int rhsMonth = rhsCalendar.get(Calendar.MONTH); int rhsYear = rhsCalendar.get(Calendar.YEAR); return (lhsMonth == rhsMonth) && (lhsYear == rhsYear); } public static Calendar getCurrentCalendar() { return getCalendarWithTime(System.currentTimeMillis()); } public static Calendar getCalendarWithTime(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); return calendar; } }