/** * @return the specified value of the specified date, * or null if the field or date is invalid. * * @param field the int for the desired field (e.g. Calendar.MONTH) * @param date the date/calendar from which the field value will be taken * @since VelocityTools 1.2 */ public Integer getValue(int field, Object date) { Calendar cal = toCalendar(date); if (cal == null) { return null; } return Integer.valueOf(cal.get(field)); }
/** * Converts an object to an instance of {@link Calendar} using the * locale returned by {@link #getLocale()} if necessary. * * @param obj the date to convert * @return the converted date * @see #toCalendar(Object obj, Locale locale) */ public Calendar toCalendar(Object obj) { return toCalendar(obj, getLocale()); }