Here you can find the source of getLastMonth(String today)
public static String getLastMonth(String today)
//package com.java2s; public class Main { public static String getLastMonth(String today) { String subYear = today.substring(0, 4); String subMonth = today.substring(5, 7); String subDay = today.substring(8, 10); Long LongMonth = new Long(subMonth); long longMonth = LongMonth.longValue(); Long LongYear = new Long(subYear); long longYear = LongYear.longValue(); String tomorrow;/* www . ja v a 2 s.com*/ if (longMonth != 1) { longMonth--; if (longMonth < 10) { tomorrow = subYear + "-" + "0" + longMonth + "-" + subDay; } else tomorrow = subYear + "-" + longMonth + "-" + subDay; } else { longMonth = 12; longYear--; tomorrow = longYear + "-" + longMonth + "-" + subDay; } return tomorrow; } }