get Current Year - Java java.util

Java examples for java.util:Year

Description

get Current Year

Demo Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getCurrentYear());
    }/* www.j  a v  a  2 s  .c  o  m*/

    public static int getCurrentYear() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.YEAR);
    }
}

Related Tutorials