Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static int getMonthDayNumber(int offset) { Calendar calendar = Calendar.getInstance(); if (offset != 0) calendar.add(Calendar.MONTH, offset); return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); } }