Java Month Calculate getNextMonth(long date)

Here you can find the source of getNextMonth(long date)

Description

Returns the next month.

License

Open Source License

Parameter

Parameter Description
date Base date

Return

next month

Declaration

public static long getNextMonth(long date) 

Method Source Code

//package com.java2s;
/*//from  www  .  j  a  v  a 2 s  . com
 * $Id: DateUtils.java,v 1.1 2004/08/12 00:24:33 dmouse Exp $
 *
 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.util.*;

public class Main {
    private static Calendar CALENDAR = Calendar.getInstance();

    /**
     * Returns the next month.
     * 
     * @param date Base date
     * @return next month
     */
    public static long getNextMonth(long date) {
        return incrementMonth(date, 1);
    }

    private static long incrementMonth(long date, int increment) {
        Calendar calendar = CALENDAR;
        synchronized (calendar) {
            calendar.setTimeInMillis(date);
            calendar.add(Calendar.MONTH, increment);
            return calendar.getTimeInMillis();
        }
    }
}

Related

  1. getMonthlyIntervals(Date start, Date end)
  2. getMonthNumber()
  3. getMonthsMap()
  4. getMonthsOfAge(Date birth, Date now)
  5. getMonthSpan(Date begin, Date end)
  6. getNextMonthExtention(Date dt, Long n)
  7. getNowMonth()
  8. getStartOfMonth(Calendar scal)
  9. getThisMonthEnd()