Package freemarker.ext.beans
Class DateModel
- java.lang.Object
-
- freemarker.ext.beans.BeanModel
-
- freemarker.ext.beans.DateModel
-
- All Implemented Interfaces:
WrapperTemplateModel
,AdapterTemplateModel
,TemplateDateModel
,TemplateHashModel
,TemplateHashModelEx
,TemplateModel
,TemplateModelWithAPISupport
public class DateModel extends BeanModel implements TemplateDateModel
Wraps arbitrary subclass ofDate
into a reflective model. Beside acting as aTemplateDateModel
, you can call all Java methods on these objects as well.
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateDateModel
DATE, DATETIME, TIME, TYPE_NAMES, UNKNOWN
-
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
-
Constructor Summary
Constructors Constructor Description DateModel(java.util.Date date, BeansWrapper wrapper)
Creates a new model that wraps the specified date object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Date
getAsDate()
Returns the date value.int
getDateType()
Returns the type of the date.-
Methods inherited from class freemarker.ext.beans.BeanModel
get, getAdaptedObject, getAPI, getWrappedObject, hasPlainGetMethod, invokeGenericGet, isEmpty, keys, keySet, size, toString, unwrap, values, wrap
-
-
-
-
Constructor Detail
-
DateModel
public DateModel(java.util.Date date, BeansWrapper wrapper)
Creates a new model that wraps the specified date object.- Parameters:
date
- the date object to wrap into a model.wrapper
- theBeansWrapper
associated with this model. Every model has to have an associatedBeansWrapper
instance. The model gains many attributes from its wrapper, including the caching behavior, method exposure level, method-over-item shadowing policy etc.
-
-
Method Detail
-
getAsDate
public java.util.Date getAsDate()
Description copied from interface:TemplateDateModel
Returns the date value. The return value must not benull
.- Specified by:
getAsDate
in interfaceTemplateDateModel
-
getDateType
public int getDateType()
Description copied from interface:TemplateDateModel
Returns the type of the date. It can be any ofTemplateDateModel.TIME
,TemplateDateModel.DATE
, orTemplateDateModel.DATETIME
.- Specified by:
getDateType
in interfaceTemplateDateModel
-
-