Java Day getLastDay(Date date)

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

Description

get Last Day

License

Open Source License

Declaration

public static int getLastDay(Date date) 

Method Source Code


//package com.java2s;

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

public class Main {
    private static SimpleDateFormat dayParse = new SimpleDateFormat("yyyy-MM-dd");

    public static int getLastDay(Date date) {

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/*from  w  w  w.  j av a  2  s . c  o m*/
        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1);
        calendar.roll(Calendar.DATE, -1);
        Date time = calendar.getTime();
        String format = dayParse.format(time);
        String[] split = format.split("-");
        String day = split[2];
        return Integer.parseInt(day);

    }
}

Related

  1. getDayText(Date day)
  2. getDayTime_End()
  3. getLastDay()
  4. getLastDay(Date date)
  5. getLastDay(Date date)
  6. getLastDay(String nowdate, String inFormat, String outFormat)
  7. getLastDayOfQuarter(Date date)
  8. getLastNDays(int aInN)
  9. getLastTimeInDay(Date day)