Java Month of Year getLastMonthdate()

Here you can find the source of getLastMonthdate()

Description

get Last Monthdate

License

Apache License

Declaration

public static Date getLastMonthdate() 

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 {
    public final static SimpleDateFormat sdf = new SimpleDateFormat();
    public final static Calendar car = Calendar.getInstance();

    public static Date getLastMonthdate() {
        car.setTimeInMillis(System.currentTimeMillis());
        return addMonth(-1);
    }//  ww w  .j  a v a2s .  co m

    public static Date addMonth(int k) {
        car.add(Calendar.MONTH, k);
        return car.getTime();
    }

    public static String getTime(String format) {
        return formatDate(new Date(), format);
    }

    public static String formatDate(Date date, String formater) {
        sdf.applyPattern(formater);
        return sdf.format(date);
    }
}

Related

  1. getLastCompletedMonthAndYear()
  2. getLastMonth()
  3. getLastMonth()
  4. getLastMonth()
  5. getLastMonthAndCycle()
  6. getLastMonthDate()
  7. getLastMonthDate(int date)
  8. getLastMonthOfQuater(Date date)
  9. getLastMonthOfYear()