Java Month Day getLastMonthLastDay()

Here you can find the source of getLastMonthLastDay()

Description

get Last Month Last Day

License

Open Source License

Declaration

public static String getLastMonthLastDay() 

Method Source Code

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

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

import java.util.Locale;

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

    public static String getLastMonthLastDay() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
        Calendar c = Calendar.getInstance();
        c.set(Calendar.DAY_OF_MONTH, 0);
        return sdf.format(c.getTime());
    }// www  .j  av a 2  s  .  c  om

    public static String format(Date date, String pattern) {
        if (date == null)
            return "";
        else
            return getFormatter(pattern).format(date);
    }

    public static String format(Date date) {
        if (date == null)
            return "";
        else
            return getFormatter(YYYY_MM_DD).format(date);
    }

    private static SimpleDateFormat getFormatter(String parttern) {
        return new SimpleDateFormat(parttern);
    }
}

Related

  1. getFirstDayOfNextMonth()
  2. getFirstDayStringOfMonth(Date date)
  3. getFirstDayStrOfMonth(Date date)
  4. getLastMonthDay()
  5. getLastMonthLastDate()
  6. getLastMonthLastDay()
  7. getLastMothStart()
  8. GetLastWorkDayofMonth(String strDateStart)
  9. getMonthDay(int year, int month)