Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**
     * Determines the Date "date" adjusted by the number of hours passed in.
     * A Negative int will go back a few hours. This always uses the current
     * date/ time as opposed to the getDateAdjustedByDays() method below which
     * uses the passed in Date argument as the base to use.
     * @param hrs Number of hours to adjust by
     * @return Returns a date object
     */
    public static Date getDateAdjustedByHours(int hrs) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.HOUR_OF_DAY, hrs);
        return cal.getTime();
    }
}