Here you can find the source of getLastDayOfMonth(int year, int month)
Parameter | Description |
---|---|
year | specified year |
month | specified month |
public static Date getLastDayOfMonth(int year, int month)
//package com.java2s; /*/*from w w w . ja v a 2s . c om*/ * File: $RCSfile$ * * Copyright (c) 2005 Wincor Nixdorf International GmbH, * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany * All Rights Reserved. * * This software is the confidential and proprietary information * of Wincor Nixdorf ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered * into with Wincor Nixdorf. */ import java.util.Date; import java.util.Calendar; public class Main { /** * Return last day of date with specified year and month * * @param year specified year * @param month specified month * @return last day value of year of current date */ public static Date getLastDayOfMonth(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); int lastDay = cal.getActualMaximum(Calendar.DATE); cal.set(Calendar.DAY_OF_MONTH, lastDay); return cal.getTime(); } }