Here you can find the source of nextMonth(Date date, int month)
Parameter | Description |
---|---|
date | Date |
month | number of next month |
public static Date nextMonth(Date date, int month)
//package com.java2s; /*/*from www . j a v a 2 s.c o m*/ * Copyright (C) 2010 Viettel Telecom. All rights reserved. * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.util.Calendar; import java.util.Date; public class Main { /** * get the next n month. * * @param date Date * @param month number of next month * @return Date */ public static Date nextMonth(Date date, int month) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + month, calendar.get(Calendar.DATE), 0, // hour 0, // min 0); // sec /** * clear millisecond field */ calendar.clear(Calendar.MILLISECOND); return calendar.getTime(); } }