Here you can find the source of isLastDayOfMonth()
public static boolean isLastDayOfMonth()
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**/*from w ww. j ava2s . c o m*/ * Checking the date of the end of Month * @return true/false */ public static boolean isLastDayOfMonth() { try { Date today = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(today); calendar.add(Calendar.MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.DATE, -1); Date lastDayOfMonth = calendar.getTime(); DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //System.out.println("Today : " + sdf.format(today)); //System.out.println("Last Day of Month: " + sdf.format(lastDayOfMonth)); if (sdf.format(today).equals(sdf.format(lastDayOfMonth))) { return true; } else { return false; } } catch (Exception e) { System.err.println("Checking isLastDayOfMonth error: " + e.getMessage()); return false; } } public static Date setTime(final Date date, final int hourOfDay, final int minute, final int second) { final GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); gc.set(Calendar.HOUR_OF_DAY, hourOfDay); gc.set(Calendar.MINUTE, minute); gc.set(Calendar.SECOND, second); return gc.getTime(); } }