Java Year Ago hasYearPassed(int year)

Here you can find the source of hasYearPassed(int year)

Description

has Year Passed

License

Apache License

Declaration

public static boolean hasYearPassed(int year) 

Method Source Code

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

import java.util.Calendar;

public class Main {
    private static Calendar NOW = Calendar.getInstance();

    public static boolean hasYearPassed(int year) {
        return normalizeYear(year) < NOW.get(Calendar.YEAR);
    }//w w  w. j a v a 2 s  .  c  o  m

    /** Expand two-digit year to four-digit if necessary. */
    public static int normalizeYear(int year) {
        if (0 <= year && year < 100) {
            int currentYear = NOW.get(Calendar.YEAR);
            year = currentYear / 100 + year;
        }
        return year;
    }
}

Related

  1. getHundredYearsAgo()
  2. yearAgo()
  3. yearsAgo(int i)
  4. yearsAgo(int n)