Java TimeZone Add isFuture(int month, int year, TimeZone timeZone, Locale locale)

Here you can find the source of isFuture(int month, int year, TimeZone timeZone, Locale locale)

Description

is Future

License

Open Source License

Declaration

public static boolean isFuture(int month, int year, TimeZone timeZone, Locale locale) 

Method Source Code

//package com.java2s;
/**//from w  ww .j av a  2  s. co  m
 * Genji Scrum Tool and Issue Tracker
 * Copyright (C) 2015 Steinbeis GmbH & Co. KG Task Management Solutions
    
 * <a href="http://www.trackplus.com">Genji Scrum Tool</a>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Calendar;

import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    public static boolean isFuture(int month, int year) {
        return isFuture(month, year, TimeZone.getDefault(), Locale.getDefault());
    }

    public static boolean isFuture(int month, int year, TimeZone timeZone, Locale locale) {

        Calendar curCal = new GregorianCalendar(timeZone, locale);
        curCal.set(Calendar.DATE, 1);

        Calendar cal = (Calendar) curCal.clone();
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.YEAR, year);

        return cal.after(curCal);
    }

    public static boolean isFuture(int month, int day, int year) {
        return isFuture(month, day, year, TimeZone.getDefault(), Locale.getDefault());
    }

    public static boolean isFuture(int month, int day, int year, TimeZone timeZone, Locale locale) {

        Calendar curCal = new GregorianCalendar(timeZone, locale);

        Calendar cal = (Calendar) curCal.clone();
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.DATE, day);
        cal.set(Calendar.YEAR, year);

        return cal.after(curCal);
    }

    public static boolean isFuture(int month, int day, int year, int hour, int minute, int amPm) {

        return isFuture(month, day, year, hour, minute, amPm, TimeZone.getDefault(), Locale.getDefault());
    }

    public static boolean isFuture(int month, int day, int year, int hour, int minute, int amPm, TimeZone timeZone,
            Locale locale) {

        Calendar curCal = new GregorianCalendar(timeZone, locale);

        Calendar cal = (Calendar) curCal.clone();
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.DATE, day);
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.HOUR, hour);
        cal.set(Calendar.MINUTE, minute);
        cal.set(Calendar.AM_PM, amPm);

        return cal.after(curCal);
    }
}

Related

  1. addTimeZone(String id, double off)
  2. adjustTimeToDefaultTimezone(long time)
  3. baseFor(TimeZone tz)
  4. cal(TimeZone tz)
  5. isAfter(int month1, int day1, int year1, int hour1, int minute1, int amPm1, int month2, int day2, int year2, int hour2, int minute2, int amPm2, TimeZone timeZone, Locale locale)
  6. millisFromEpochToHourId(long millis, TimeZone tz)
  7. nowWithTimeZone(TimeZone timezone)
  8. removeTimeZoneOffset(long t)
  9. shiftDate(Date date, TimeZone timeZone, String pattern)