Here you can find the source of getMonthStartDateBeforeCurrent(int monthNum, Date current)
public static long getMonthStartDateBeforeCurrent(int monthNum, Date current)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static long getMonthStartDateBeforeCurrent(int monthNum, Date current) { Calendar calendar = Calendar.getInstance(); calendar.setTime(current);/*from w w w .ja v a 2 s . c o m*/ // calendar.set(Calendar.MONTH, -monthNum + 2); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MONTH, -monthNum); return calendar.getTimeInMillis(); } }