get Current Year - Android java.util

Android examples for java.util:Year

Description

get Current Year

Demo Code

import android.text.format.Time;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main{

    public static int getNowYear() {
        Time time = new Time("GMT+8");
        time.setToNow();//  www.  ja v a  2 s.  com
        int year = time.year;
        return year;
    }

}

Related Tutorials