Here you can find the source of getYear(Calendar calendar)
Parameter | Description |
---|---|
calendar | the calendar |
private static int getYear(Calendar calendar)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.GregorianCalendar; public class Main { /**/*from ww w.j av a 2s. com*/ * Get the year (positive or negative) from a calendar. * * @param calendar the calendar * @return the year */ private static int getYear(Calendar calendar) { int year = calendar.get(Calendar.YEAR); if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) { year = 1 - year; } return year; } }