Java Year Get getYear(String argDate)

Here you can find the source of getYear(String argDate)

Description

This method is used to retrieve the year

License

Open Source License

Parameter

Parameter Description
argDate a parameter

Exception

Parameter Description
DAOException an exception

Return

int

Declaration

public static int getYear(String argDate) 

Method Source Code

//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    /**/*www . ja v  a  2 s . c  om*/
     * This method is used to retrieve the year
     * 
     * @param argDate
     * @return int
     * @throws DAOException
     */
    public static int getYear(String argDate) {
        SimpleDateFormat dtFormat = new SimpleDateFormat("MM/dd/yyyy");
        Calendar calendar = Calendar.getInstance();
        int year = 0;
        try {
            calendar.setTime(dtFormat.parse(argDate));
            year = calendar.get((Calendar.YEAR)) - 1;
        } catch (ParseException eParse) {
        }

        return year;
    }
}

Related

  1. getYear(final String date)
  2. getYear(int year)
  3. getYear(long date)
  4. getYear(String aDate)
  5. GetYear(String agmipDate)
  6. getYear(String date)
  7. getYear(String date)
  8. getYear(String date)
  9. getYear(String date)