Here you can find the source of nextMonth()
public static final int nextMonth()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final int nextMonth() { String next = format(new Date(), "M"); int nextMonth = Integer.parseInt(next) + 1; if (nextMonth == 13) return 1; return nextMonth; }/* w ww.ja v a 2 s . c o m*/ /** * @param date * @param pattern: Date format pattern * @return */ public static final <T extends Date> String format(T date, String pattern) { if (date == null) return null; try { SimpleDateFormat df = new SimpleDateFormat(pattern); String result = df.format(date); return result; } catch (Exception e) { return null; } } }