get Next Day From Number - Java java.util

Java examples for java.util:Day

Description

get Next Day From Number

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        int year = 2;
        int month = 2;
        int day = 2;
        System.out.println(getNextDayFromNumber(year, month, day));
    }// www.  j  a va  2s  .  c om

    public static Calendar getNextDayFromNumber(int year, int month, int day) {
        return getCalendarFromNumber(year, month, day + 1, 0);
    }

    public static Calendar getCalendarFromNumber(int year, int month,
            int day, int hour) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month);
        calendar.set(Calendar.DAY_OF_MONTH, day);
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar;
    }
}

Related Tutorials