Java Week Calculate nextWeek(long date)

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

Description

Returns the week after date.

License

Open Source License

Parameter

Parameter Description
date Date used in calculating next week

Return

week after date.

Declaration

public static long nextWeek(long date) 

Method Source Code

//package com.java2s;
/*// ww  w  .  j ava2s . c om
 * $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 week after <code>date</code>.
     *
     * @param date Date used in calculating next week
     * @return week after <code>date</code>.
     */
    public static long nextWeek(long date) {
        return addDays(date, 7);
    }

    /**
     * Adds <code>amount</code> days to <code>time</code> and returns
     * the resulting time.
     *
     * @param time Base time
     * @param amount Amount of increment.
     */
    public static long addDays(long time, int amount) {
        Calendar calendar = CALENDAR;
        synchronized (calendar) {
            calendar.setTimeInMillis(time);
            calendar.add(Calendar.DAY_OF_MONTH, amount);
            return calendar.getTimeInMillis();
        }
    }
}

Related

  1. getWeekOfYear(Date date, Locale locale)
  2. getWeeksAddCount(int repType, int repIndex)
  3. getWeeksInYear(int year)
  4. isSameWeekDates(Date date1, Date date2)
  5. nextWeek(Date date, int week)
  6. plusHour(Date date, int plusWeek)
  7. startOfWeek(Date datum)
  8. weekCal(int weekNumber)
  9. weekCount(Date start, Date end)