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(String date)
Get year
return Integer.parseInt(date.substring(0, 4));
StringgetYear(String date)
get Year
return date.substring(6);
intgetYear(String dateKey)
Get the year of the date key.
return Integer.valueOf(dateKey.substring(0, 4));
intgetYear(String datetime)
get Year
Calendar cal = Calendar.getInstance();
cal.setTime(parseDate(datetime));
return cal.get(Calendar.YEAR);
intgetYear(String day)
get Year
if (day == null)
    return 0;
if (day.length() < 8)
    return 0;
return Integer.parseInt(day.substring(0, 4));
intgetYear(String index)
get Year
String[] dateTmp = index.split("-");
return Integer.parseInt(dateTmp[1]);
StringgetYear(String referralId)
Get the full year from the referral id.
return "20" + parse(referralId)[2];
intgetYear(String startTime)
get Year
int year = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
try {
    year = sdf.parse(startTime).getYear() + 1900;
} catch (Exception ex) {
    ex.printStackTrace();
return year;
...
StringgetYear(String str_date)
get Year
return getYear(str_date, "-");
intgetYear(String strDate)
get Year
Calendar cale = toCalendar(strDate);
if (cale == null) {
    return -1;
return cale.get(Calendar.YEAR);