Java Day of Month getLastDateOfCurMonth()

Here you can find the source of getLastDateOfCurMonth()

Description

get Last Date Of Cur Month

License

Open Source License

Declaration

public static String getLastDateOfCurMonth() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    private static final String date_pattern = "yyyy-MM-dd";

    public static String getLastDateOfCurMonth() {
        String curYearMonth = getCurYearMonth();

        Calendar calendar = Calendar.getInstance();
        int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        return curYearMonth + "-" + maxDay;
    }/*  w w w  .  j  a va2 s .  c  o m*/

    public static String getCurYearMonth() {
        String curTime = getCurDate();
        String curYearMonth = curTime.substring(0, 7);
        return curYearMonth;
    }

    public static String getCurDate() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat(date_pattern);
        return format.format(date);
    }

    public static String getCurDate(String fmt) {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat(fmt);
        return format.format(date);
    }
}

Related

  1. getFirstDayOfMonth(Date date)
  2. getFirstDayOfMonth(java.util.Date date)
  3. getFirstMiddleDayOfMonth(Date date)
  4. getFistDayOfMonth(Date date)
  5. getFromDate(boolean invoiceSearchFromFirstDayOfMonth)
  6. getLastDay(int year, int month)
  7. getLastDayByMonthWeek(int year, int month, int week)
  8. getLastDayInMonth(int year, int month)
  9. getLastDayOfCurMonth()