Java Month Day getDaysOfMonth(Date date)

Here you can find the source of getDaysOfMonth(Date date)

Description

get Days Of Month

License

Apache License

Declaration

public static int getDaysOfMonth(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static int getDaysOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);//from  w ww  .j a v  a  2s .co  m
        return c.getActualMaximum(5);
    }

    public static int getDaysOfMonth(Date startMonth, Integer monthSeq) {
        Date month = getMonthByOffset(startMonth, monthSeq.intValue() - 1);
        return getDaysOfMonth(month);
    }

    public static Date getMonthByOffset(Date date, int offset) {
        Calendar calendar = Calendar.getInstance();
        if (null != date) {
            calendar.setTime(date);
            calendar.set(5, 1);
            calendar.set(11, 0);
            calendar.set(12, 0);
            calendar.set(13, 0);
            calendar.set(14, 0);
        }
        calendar.add(2, offset);
        return calendar.getTime();
    }
}

Related

  1. getCurretnMonthFirstDay()
  2. getCurrMonthFirstDay()
  3. getDayOfMonth()
  4. getDaysInMonth(final Date date)
  5. getDaysOfMonth(Date date)
  6. getFirstDate(String base_month)
  7. getFirstDateOfCurMonth()
  8. getFirstDateOfMonth(Date theDate)
  9. getFirstday_Month(Date date, int months)