set Previous Month - Java java.util

Java examples for java.util:Month

Description

set Previous Month

Demo Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar calendar = Calendar.getInstance();
        System.out.println(setPrevMonth(calendar));
    }/*from w ww.j av  a2 s  . c  o m*/

    public static Calendar setPrevMonth(Calendar calendar) {
        calendar.add(Calendar.MONTH, -1);
        return calendar;
    }
}

Related Tutorials