get Year from Date and return int - Android java.util

Android examples for java.util:Year

Description

get Year from Date and return int

Demo Code


//package com.java2s;

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

public class Main {
    public static int getYear(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);/*from   w  ww .  j a va2 s  .  c om*/
        return c.get(Calendar.YEAR);
    }
}

Related Tutorials