Java Week Calculate plusHour(Date date, int plusWeek)

Here you can find the source of plusHour(Date date, int plusWeek)

Description

plus Hour

License

Apache License

Declaration

public static Date plusHour(Date date, int plusWeek) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.//from   www  . ja v a 2  s. co  m
 *******************************************************************************/

import java.util.*;

public class Main {
    public static Date plusHour(Date date, int plusWeek) {
        return plusInteger(date, Calendar.HOUR, plusWeek);
    }

    private static Date plusInteger(Date date, int dateType, int amount) {
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.add(dateType, (0 - amount));
            date = calendar.getTime();
        }
        return date;
    }
}

Related

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