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(Date d)
Get the year from a Date object.
return Integer.parseInt(new SimpleDateFormat("yyyy").format(d));
intgetYear(Date date)
get Year
calendar.setTime(date);
return calendar.get(Calendar.YEAR);
intgetYear(Date date)
get Year
final GregorianCalendar utcCalendar = createUtcCalendar(date);
return utcCalendar.get(Calendar.YEAR);
intgetYear(Date date)
get Year
return getDatePar(Calendar.YEAR, date);
StringgetYear(Date date)
get Year
return new SimpleDateFormat("yyyy").format(date);
StringgetYear(Date date)
get Year
DateFormat df = new SimpleDateFormat("yyyy");
df.setLenient(false);
return df.format(date);
StringgetYear(Date date)
get Year
return FormatDate(date, "yyyy");
intgetYear(Date date)
get Year
return getCalendar(date).get(Calendar.YEAR);
intgetYear(Date date, TimeZone timeZone)
get Year
if (date == null)
    throw new IllegalArgumentException("date is required.");
if (timeZone == null)
    timeZone = TimeZone.getDefault();
_fmtYear.setTimeZone(timeZone);
try {
    return Integer.parseInt(_fmtYear.format(date));
} catch (NumberFormatException e) {
...
StringgetYear(Date dt)
Get year string for the specified date.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
StringBuffer sb = new StringBuffer();
sdf.format(dt, sb, new FieldPosition(0));
return sb.toString();