Java Year Current getYear()

Here you can find the source of getYear()

Description

get Year

License

Apache License

Declaration

public static int getYear() 

Method Source Code


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

import static java.util.Calendar.*;

import java.util.*;

public class Main {
    public static int getYear() {
        return getYear(new Date()).intValue();
    }//  w w  w. jav  a  2 s  . c om

    public static Integer getYear(Date date) {
        if (date == null) {
            return null;
        }

        Calendar ca = Calendar.getInstance();
        ca.setTime(date);
        return Integer.valueOf(ca.get(YEAR));
    }
}

Related

  1. getCurrYear()
  2. getCurrYearFirst()
  3. getLastDayOfCurrentYear()
  4. getYear()
  5. getYear()
  6. getYear()
  7. getYear()
  8. getYear()
  9. getYear()