Java Month Get getMonthBefore(Date d, int number)

Here you can find the source of getMonthBefore(Date d, int number)

Description

get Month Before

License

Open Source License

Declaration

public static String getMonthBefore(Date d, int number) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static String getMonthBefore(Date d, int number) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.MONTH, number);
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        return formatter.format(calendar.getTime());
    }//  ww w  . j  a  va  2  s  .  c o m
}

Related

  1. getMonth(String strDate)
  2. getMonth(String tempdat, Locale locale)
  3. getMonth1D()
  4. getMonthAdd(String operateDate, int flag)
  5. getMonthAndDate()
  6. getMonthBegin(String strdate)
  7. getMonthBegin(String strdate)
  8. getMonthByNow(int month)
  9. getMonthCount(String from, String to)