Java Month of Year getLastMonth()

Here you can find the source of getLastMonth()

Description

get Last Month

License

Open Source License

Declaration

public static String getLastMonth() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * @(#)TimeUtil.java 2010-2-1/*  w w w.  j a  va 2s.  c  o  m*/
 *
 * Copyright 2010 Neusoft Group Ltd. All rights reserved.
 * Neusoft PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *******************************************************************************/

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

public class Main {

    public static String getLastMonth() {
        final Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, -1);
        final Date date = calendar.getTime();
        final SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM");
        return formatter.format((date));
    }
}

Related

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