Here you can find the source of getYear(String argDate)
Parameter | Description |
---|---|
argDate | a parameter |
Parameter | Description |
---|---|
DAOException | an exception |
public static int getYear(String argDate)
//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; } }