Get the year from a calendar to a string. - Android java.util

Android examples for java.util:Year

Description

Get the year from a calendar to a string.

Demo Code


//package com.java2s;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    /**/*from   w  ww. j a  v  a2 s  .co  m*/
     * Get the year from a calendar to a string.
     * @param calendar The Calendar to convert.
     * @return The formatted year.
     */
    public static String convertToYearString(GregorianCalendar calendar) {
        return Integer.toString(calendar.get(Calendar.YEAR));
    }
}

Related Tutorials