Here you can find the source of getThisMonthEnd()
public static String getThisMonthEnd()
//package com.java2s; import java.util.*; public class Main { public static String getThisMonthEnd() { String strY = null;//from w ww .j a va 2s . c o m String strZ = null; boolean leap = false; Calendar localTime = Calendar.getInstance(); int x = localTime.get(Calendar.YEAR); int y = localTime.get(Calendar.MONTH) + 1; if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) { strZ = "31"; } if (y == 4 || y == 6 || y == 9 || y == 11) { strZ = "30"; } if (y == 2) { leap = leapYear(x); if (leap) { strZ = "29"; } else { strZ = "28"; } } strY = y >= 10 ? String.valueOf(y) : ("0" + y); return x + "-" + strY + "-" + strZ; } public static boolean leapYear(int year) { boolean leap; if (year % 4 == 0) { if (year % 100 == 0) { if (year % 400 == 0) leap = true; else leap = false; } else leap = true; } else leap = false; return leap; } }