Java Utililty Methods Year Get

List of utility methods to do Year Get

Description

The list of methods to do Year Get are organized into topic(s).

Method

intgetYear(final Date date)
get Year
if (date == null) {
    return 0;
Calendar cal = new GregorianCalendar();
cal.setTime(date);
return cal.get(Calendar.YEAR);
StringgetYear(final String date)
get Year
String year = null; 
if (date != null && !date.isEmpty()) {
    final DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.ENGLISH);
    final Calendar cal = Calendar.getInstance(Locale.ENGLISH);
    cal.setTime(df.parse(date));
    year = String.valueOf(cal.get(Calendar.YEAR));
return year;
...
StringgetYear(final String date)
DOCUMENT ME!
return date.substring(6);
StringgetYear(int year)
get Year
return Integer.toString(year);
intgetYear(long date)
get Year
return (int) (date / YEAR_OFFSET);
intgetYear(String aDate)
get Year
int myYear = -1;
if (isValidObjectModelDate(aDate)) {
    Integer Year = new Integer(aDate.substring(0, 4));
    myYear = Year.intValue();
return myYear;
StringGetYear(String agmipDate)
Get Year
Date date = apsim.parse(agmipDate);
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.get(Calendar.YEAR) + "";
intgetYear(String argDate)
This method is used to retrieve the year
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;
IntegergetYear(String date)
get Year
if (date == null) {
    return null;
String year = null;
if (date.contains(".")) {
    year = date.substring(date.lastIndexOf('.') + 1);
} else if (date.contains("-")) {
    year = date.substring(0, date.indexOf('-'));
...
intgetYear(String date)
get Year
date = deleteSlash(date);
date = deleteDash(date);
return Integer.parseInt(date.substring(0, 4));