Java Month Day lastDayOfMonth(String batdate)

Here you can find the source of lastDayOfMonth(String batdate)

Description

last Day Of Month

License

Open Source License

Declaration

public static String lastDayOfMonth(String batdate) 

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 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);
    }
}

Related

  1. isFirstDayOfMonth()
  2. isLastDayOfMonth()
  3. isLastDayOfMonth(Calendar cal)
  4. lastDayOfLastMonth()
  5. lastdayofmonth()
  6. lastDayOfMonth(String src)
  7. previousMonthFirstDay()