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 "days".
     * A negative value will return a date in the past.
     * @param date The date to be adjusted
     * @param days The number of days to adjust by
     * @return Returns a date object
     */
    public static Date getDateAdjustedByDays(Date date, int days) {
        Calendar cal = Calendar.getInstance();
        if (date != null)
            cal.setTime(date);
        cal.add(Calendar.DAY_OF_YEAR, days);
        return cal.getTime();
    }
}