Here you can find the source of getSecondsOfMonth(int year, int month)
public static int getSecondsOfMonth(int year, int month)
//package com.java2s; /*/*from w w w . j a v a 2 s .com*/ * 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 { public static int getSecondsOfMonth(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, 1, 0, 0, 0); Calendar calendarNextMonth = (Calendar) calendar.clone(); calendarNextMonth.add(Calendar.MONTH, 1); return new Long((calendarNextMonth.getTimeInMillis() - calendar.getTimeInMillis()) / 1000).intValue(); } /** * Add Interval to Date * * @param inputDate Date to Add * @param interval Interval to added. Subtract is interval is nagative * @param calendarUnit Calendar.Year/Calendar.Month/Calendar.Day/Calendar.Hour/Calendar.MInute * @return Date added */ public static Date add(Date inputDate, int interval, int calendarUnit) { Calendar cal = Calendar.getInstance(); cal.setTime(formateDateWithoutTime(inputDate)); cal.add(calendarUnit, interval); return cal.getTime(); } /** * Format Date to make it''s hour/minute/second to 0 * * @param inputDate Date to Format * @return Date with Year/Month/Day is same with input one while hour/minute/second is 0 */ public static Date formateDateWithoutTime(Date inputDate) { Date outputDate = inputDate; Calendar cal = Calendar.getInstance(); cal.setTime(outputDate); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); outputDate = cal.getTime(); return outputDate; } }