Java Day of Month getLastDayOfCurMonth()

Here you can find the source of getLastDayOfCurMonth()

Description

get Last Day Of Cur Month

License

Open Source License

Declaration

public static String getLastDayOfCurMonth() 

Method Source Code

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

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

import java.util.GregorianCalendar;

public class Main {

    public static String getLastDayOfCurMonth() {
        Calendar calendar = new GregorianCalendar();
        calendar.set(Calendar.DATE, 1);
        calendar.roll(Calendar.DATE, -1);
        SimpleDateFormat simpleFormate = new SimpleDateFormat("yyyy-MM-dd");
        return simpleFormate.format(calendar.getTime()).trim();
    }/*w w  w .  j  a v a  2s. co m*/

    public static String format(java.util.Date date, String format) {
        String result = "";
        try {
            if (date != null) {
                java.text.DateFormat df = new java.text.SimpleDateFormat(format);
                result = df.format(date);
            }
        } catch (Exception e) {
        }
        return result;
    }

    public static String format(java.util.Date date) {
        return format(date, "yyyy/MM/dd");
    }

    public static String getTime(java.util.Date date) {
        return format(date, "HH:mm:ss");
    }
}

Related

  1. getFromDate(boolean invoiceSearchFromFirstDayOfMonth)
  2. getLastDateOfCurMonth()
  3. getLastDay(int year, int month)
  4. getLastDayByMonthWeek(int year, int month, int week)
  5. getLastDayInMonth(int year, int month)
  6. getLastDayOfLastMonth()
  7. getLastDayOfMonth()
  8. getLastdayofMonth()
  9. getlastDayOfMonth()