Java Date to Year getYear(Date start)

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

Description

get Year

License

Apache License

Declaration

public static int getYear(Date start) 

Method Source Code


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

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

public class Main {
    public static int getYear(Date start) {

        Calendar c = Calendar.getInstance();
        c.setTime(start);//from  www.ja va 2s .  co m
        Calendar now = Calendar.getInstance();

        int count = 0;
        for (;;) {
            c.add(Calendar.YEAR, 1);
            count++;

            if (c.after(now)) {
                break;
            }
        }
        return count;
    }
}

Related

  1. getYear(Date date)
  2. getYear(Date date)
  3. getYear(Date date)
  4. getYear(Date date)
  5. getYear(Date dateParam)
  6. getYear(final Date date)
  7. getYear(final Date date)
  8. getYear(final Date date)
  9. getYear(java.util.Date date)