get Last Month - Java java.util

Java examples for java.util:Month

Description

get Last Month

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getLastMonth());
    }/*from www. j  a v  a2 s  . c o  m*/

    public static int getLastMonth() {
        Calendar temp = Calendar.getInstance();
        temp.add(Calendar.MONTH, -1);
        return temp.get(Calendar.MONTH) + 1;
    }
}

Related Tutorials