Java Year Current getYear()

Here you can find the source of getYear()

Description

get Year

License

Open Source License

Declaration

public static int getYear() 

Method Source Code

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

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

public class Main {
    public static int getYear() {
        Calendar calendar = new GregorianCalendar();
        Date trialTime = new Date();
        calendar.setTime(trialTime);/* w w w .  jav a  2 s.  c  o  m*/
        return calendar.get(Calendar.YEAR);
    }

    public static int getYear(Date date) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        return calendar.get(Calendar.YEAR);
    }
}

Related

  1. getYear()
  2. getYear()
  3. getYear()
  4. getYear()
  5. getYear()
  6. getYear()
  7. year()
  8. year()
  9. year()