snap Forward Num Days - Java java.util

Java examples for java.util:Day

Description

snap Forward Num Days

Demo Code

/*******************************************************************************
 * Copyright (c) 2004, 2009 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://ww w .ja  v  a 2  s  . co  m
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/
//package com.java2s;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar calendar = Calendar.getInstance();
        int days = 2;
        System.out.println(snapForwardNumDays(calendar, days));
    }

    private static int endHour = 17;

    public static Calendar snapForwardNumDays(Calendar calendar, int days) {
        calendar.add(Calendar.DAY_OF_MONTH, days);
        calendar.set(Calendar.HOUR_OF_DAY, endHour);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar;
    }
}

Related Tutorials