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.Calendar;
import java.util.Date;

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

    public static String getLastMonth() {
        Calendar a = Calendar.getInstance();
        a.setTime(new Date());
        a.set(Calendar.DAY_OF_MONTH, -1);
        return monthFormat.format(a.getTime());
    }/*  w w w  .ja va2  s . c  om*/
}

Related

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