Get current year as String - Android java.util

Android examples for java.util:Year

Description

Get current year as String

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    /**/*w  ww . j ava 2  s  .co  m*/
     * Get current year
     * @return year in String format
     */
    public static String currentYear() {
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        return String.valueOf(year);
    }
}

Related Tutorials