Here you can find the source of getPreviousMonth(long date)
Parameter | Description |
---|---|
date | Base date |
public static long getPreviousMonth(long date)
//package com.java2s; import java.util.Calendar; public class Main { private static Calendar CALENDAR = Calendar.getInstance(); /**//from ww w.j a va 2 s.c om * Returns the previous month. * * @param date Base date * @return previous month */ public static long getPreviousMonth(long date) { return incrementMonth(date, -1); } private static long incrementMonth(long date, int increment) { Calendar calendar = CALENDAR; synchronized (calendar) { calendar.setTimeInMillis(date); calendar.add(Calendar.MONTH, increment); return calendar.getTimeInMillis(); } } }