Java examples for java.util:Month
get Next Month
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { Date date = new Date(); System.out.println(getNextMonth(date)); }/* w w w. j a v a 2 s . com*/ public static Date getNextMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); if (calendar.get(Calendar.MONTH) == Calendar.DECEMBER) { calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 1); } else { calendar.roll(Calendar.MONTH, true); } return calendar.getTime(); } }