Java Month Day getMonthLastDay(String curmonth, int month)

Here you can find the source of getMonthLastDay(String curmonth, int month)

Description

get Month Last Day

License

Open Source License

Declaration

public static String getMonthLastDay(String curmonth, int month) throws ParseException 

Method Source Code


//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 getMonthLastDay(String curmonth, int month) throws ParseException {

        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM");
        Date mydate = formatter.parse(curmonth);
        Calendar cal = Calendar.getInstance();
        cal.setTime(mydate);/*from ww w .  ja  v a2 s  . co m*/
        cal.add(Calendar.MONTH, month);

        SimpleDateFormat daytime = new SimpleDateFormat("yyyyMMdd");
        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
        return daytime.format(cal.getTime());
    }
}

Related

  1. getMonthFirstDay(T date)
  2. getMonthFristWeekSunday(String month)
  3. getMonthLastDay()
  4. getMonthLastDay()
  5. getMonthLastDay()
  6. getMonthLastDay(String dateString)
  7. getMonthLastDay(String fmt)
  8. getMonthMaxDay(String sDate)
  9. getMonthWeek(String curday)