Here you can find the source of getLastDay(Date date)
public static int getLastDay(Date date)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static SimpleDateFormat dayParse = new SimpleDateFormat("yyyy-MM-dd"); public static int getLastDay(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*from w w w. j av a 2 s . c o m*/ calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1); calendar.roll(Calendar.DATE, -1); Date time = calendar.getTime(); String format = dayParse.format(time); String[] split = format.split("-"); String day = split[2]; return Integer.parseInt(day); } }