Here you can find the source of getPreviosMonthFirstDay()
public static String getPreviosMonthFirstDay()
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static String getPreviosMonthFirstDay() { String curYearMonth = getDateTime6String(); String yearMonth = getPreviousYearMonth(curYearMonth); return yearMonth.substring(0, 4) + "-" + yearMonth.substring(4) + "-01"; }/*from w ww. j a va 2 s . co m*/ public static String getDateTime6String() { return new SimpleDateFormat("yyyyMM").format(nowDate()); } public static String getPreviousYearMonth(String currentYearMonth) { int year = Integer.parseInt(currentYearMonth.substring(0, 4)); int month = Integer.parseInt(currentYearMonth.substring(4)); if (month == 1) { year -= 1; month = 12; } else { month -= 1; } StringBuffer strb = new StringBuffer().append(year); if (month > 9) strb.append(month); else strb.append("0").append(month); return strb.toString(); } public static java.util.Date nowDate() { return new java.util.Date(); } }