Android Day in Month Get getLastDayOfMonth(String format)

Here you can find the source of getLastDayOfMonth(String format)

Description

get Last Day Of Month

Declaration

public static String getLastDayOfMonth(String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {

    public static String getLastDayOfMonth(String format) {
        String strDate = null;//from w  w  w  .j a v a 2  s  . c  om
        try {
            Calendar c = new GregorianCalendar();
            SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(
                    format);
            // ???????????
            c.set(Calendar.DATE, 1);
            c.roll(Calendar.DATE, -1);
            strDate = mSimpleDateFormat.format(c.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return strDate;
    }
}

Related

  1. dayNumber(Date date)
  2. getDayOfWeek(long time)
  3. getStringDayOfMonth(Date date)
  4. getFirstDayOfMonth(String format)
  5. getFirstDayOfMonth(String format)
  6. getLastDayOfMonth(String format)
  7. firstDayOfMonth(Date date)
  8. lastDayOfMonth(Date date)
  9. monthDays(int y, int m)