Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static int getYesterdayMonth() { long ts = System.currentTimeMillis() - 24 * 3600000; Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(ts); return calendar.get(Calendar.MONTH) + 1; } }