Java Calendar Year getYear(Calendar calendar)

Here you can find the source of getYear(Calendar calendar)

Description

Get the year (positive or negative) from a calendar.

License

Open Source License

Parameter

Parameter Description
calendar the calendar

Return

the year

Declaration

private static int getYear(Calendar calendar) 

Method Source Code

//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;
    }
}

Related

  1. getValidCalendar(int year, int month, int day)
  2. getWeekOfYear(Calendar currentDate)
  3. getWeekOfYear(int startDay, Calendar dt)
  4. getWeekOfYearYear(GregorianCalendar cal)
  5. getYear(Calendar cal)
  6. getYear(Calendar calendar)
  7. getYear(Calendar calendar)
  8. getYear(Date date, Calendar cal)
  9. getYearForWeek(final Calendar cal)