Java Year Get getYear()

Here you can find the source of getYear()

Description

get Year

License

LGPL

Declaration

public static int getYear() 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static int getYear() {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(getDate());/*from w w w  . j  a v a 2  s  .co  m*/
        return calendar.get(Calendar.YEAR);
    }

    public static Date getDate() {
        return new Date();
    }

    public static Date getDate(long millis) {
        return new Date(millis);
    }

    public static String getDate(String format) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}

Related

  1. getTwoDigitYear()
  2. getTwoYearsBefore(int date)
  3. getWeekOfYear(Date date)
  4. getWeekStartEndDate(int timeInfo, String yearInfo)
  5. getYear()
  6. getYear()
  7. getYear()
  8. getYear()
  9. getYear()