public class MonthsBack { private final static DateFormat df = new SimpleDateFormat("yyyyMM"); public static String mminus(String t, int m) throws ParseException { Calendar c = new GregorianCalendar(); c.setTime(df.parse(t)); c.add(Calendar.MONTH, -m); return df.format(c.getTime()); } public static void main(String[] args) throws Exception { System.out.println(mminus("200309",11)); } }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.