Java Year Get getYear(Date date)

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

Description

get Year

License

Apache License

Declaration

public static int getYear(Date date) 

Method Source Code

//package com.java2s;
/**/* w w w .  j  a  v a 2 s.  co m*/
  *  Copyright (c) 2014 http://www.lushapp.wang
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  */

import java.util.*;

public class Main {
    public static int getYear(Date date) {
        return getDatePar(Calendar.YEAR, date);
    }

    public static int getDatePar(int par, Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int result = calendar.get(par);
        switch (par) {
        case Calendar.MONTH:
            result++;
        }
        return result;
    }
}

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, TimeZone timeZone)
  7. getYear(Date dt)
  8. getYear(final Date date)
  9. getYear(final String date)