in myfaces-html5-core/src/main/java/org/apache/myfaces/html5/validator/DateTimeRangeValidator.java [190:224]
private Date _resolveDateFromObject(Object value, String type) throws ParseException
{
if (value == null)
return null;
if (value instanceof String)
{
String strValue = (String) value;
return Html5DateTimeFormatUtils.parseDateTime(strValue, type);
}
else if (value instanceof Date)
{
Date dateValue = (Date) value;
if (HTML5.INPUT_TYPE_TIME.equals(type))
{
// XXX: may be it's better to leave this operation to user?
// we need to clear the date info (y, m, d) if the type is "time"
Calendar cal = Calendar.getInstance();
cal.setTime(dateValue);
cal.set(Calendar.YEAR, 1970);
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH, 1);
return cal.getTime();
}
else
{
return dateValue;
}
}
else
{
throw new IllegalArgumentException("Value " + type + "is not String nor java.util.Date. Unable to resolve.");
}
}