Here you can find the source of lastDayOfMonth(String batdate)
public static String lastDayOfMonth(String batdate)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String lastDayOfMonth(String batdate) { Calendar cal = Calendar.getInstance(); Date date = null;// w ww.j a v a 2 s . co m try { date = new SimpleDateFormat("yyyyMMdd").parse(batdate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } cal.setTime(date); cal.set(Calendar.DAY_OF_MONTH, 1); cal.roll(Calendar.DAY_OF_MONTH, -1); date = cal.getTime(); return new SimpleDateFormat("yyyyMMdd").format(date); } }