Here you can find the source of getMonthEndDay(String yyyy, String mm)
public static String getMonthEndDay(String yyyy, String mm) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; public class Main { public static String getMonthEndDay(String yyyy, String mm) throws ParseException { if (yyyy == null || yyyy.trim().equals("")) { yyyy = getYear();/* www . java 2 s . c o m*/ } if (mm == null || mm.trim().equals("")) { mm = getMonth(); } int year = Integer.parseInt(yyyy); int month = Integer.parseInt(mm); int day = 0; String endDay = ""; Calendar cal = new GregorianCalendar(); cal.set(year, month, 0); year = cal.get(cal.YEAR); month = cal.get(cal.MONTH) + 1; day = cal.getActualMaximum(cal.DAY_OF_MONTH); endDay = year + String.format("%02d", month) + String.format("%02d", day); return endDay; } public static String getYear() throws ParseException { Date date = new Date(); SimpleDateFormat formatter; String pattern = "yyyy"; formatter = new SimpleDateFormat(pattern, new Locale("ko", "KOREA")); return formatter.format(date); } public static String getMonth() throws ParseException { Date date = new Date(); SimpleDateFormat formatter; String pattern = "MM"; formatter = new SimpleDateFormat(pattern, new Locale("ko", "KOREA")); return formatter.format(date); } }