Java Month of Year getLastMonth()

Here you can find the source of getLastMonth()

Description

get Last Month

License

Apache License

Declaration

public static String getLastMonth() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.GregorianCalendar;

public class Main {
    public static String getLastMonth() {
        GregorianCalendar now = new GregorianCalendar();
        now.add(2, -1);// w  ww  . j  a  v a  2 s .  c o  m
        return format(now.getTime(), "yyyyMM");
    }

    public static String format(java.util.Date date) {
        return date == null ? "" : format(date, "yyyy-MM-dd");
    }

    public static String format(java.util.Date date, String pattern) {
        return date == null ? "" : new SimpleDateFormat(pattern).format(date);
    }
}

Related

  1. getFirstMonthOfThisYear()
  2. getFirstTimeOfDay(int year, int month, int day)
  3. getLastCompletedMonthAndYear()
  4. getLastMonth()
  5. getLastMonth()
  6. getLastMonthAndCycle()
  7. getLastMonthdate()
  8. getLastMonthDate()
  9. getLastMonthDate(int date)