Here you can find the source of getPreMonthDayStr(String curday)
public static String getPreMonthDayStr(String curday)
//package com.java2s; //License from project: Apache License public class Main { public static String getPreMonthDayStr(String curday) { int year = getYear(curday); String monthStr = getMonth(curday); int month = Integer.parseInt(monthStr); if (month <= 1) { month = 12;// w w w . j a va2s .c o m year = year - 1; } else month = month - 1; monthStr = String.valueOf(month); if (monthStr.length() == 1) monthStr = "0" + monthStr; return year + "-" + monthStr + "-01"; } public static int getYear(String day) { if (day == null) return 0; if (day.length() < 8) return 0; return Integer.parseInt(day.substring(0, 4)); } public static String getMonth(String day) { if (day == null) return "0"; if (day.length() < 8) return "0"; int m = day.indexOf("-", 0); int n = day.lastIndexOf("-"); String temp = day.substring(m + 1, n); if (temp.length() == 1) temp = "0" + temp; return temp; } }