Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.sql.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    /**
     * Method to check if a date is tomorrow
     * 
     * @param theDate
     *            the date to see if it is tomorrow
     * @return true of it is tomorrow
     */
    public static boolean isTomorrow(Date theDate) {
        // Get a calendar with the events start time
        GregorianCalendar theCalendar = new GregorianCalendar();
        theCalendar.setTime(theDate);
        // Get a calendar with current system time and change its value so it
        // can be used in comparison with the given date.
        Calendar tmpDate = Calendar.getInstance();
        tmpDate.roll(Calendar.DAY_OF_YEAR, true);

        return tmpDate.get(Calendar.YEAR) == theCalendar.get(Calendar.YEAR)
                && tmpDate.get(Calendar.DAY_OF_YEAR) == theCalendar.get(Calendar.DAY_OF_YEAR);
    }
}