Java Date to Year getYear(Date date)

Here you can find the source of getYear(Date date)

Description

Retrieve a year of a full date

License

Open Source License

Parameter

Parameter Description
date The full date

Return

int - The year of the date

Declaration

public static int getYear(Date date) 

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 {
    /**//from w w w  .ja  v a 2 s.  c  o  m
     * Retrieve a year of a full date
     * 
     * @param date
     *            The full date
     * @return int - The year of the date
     */
    public static int getYear(Date date) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        int year = calendar.get(Calendar.YEAR);
        return year;
    }
}

Related

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