org.zkoss.zkplus.databind
Class DateFormatConverter

java.lang.Object
  extended by org.zkoss.zkplus.databind.DateFormatConverter
All Implemented Interfaces:
TypeConverter

public class DateFormatConverter
extends java.lang.Object
implements TypeConverter

Convert a Date or a Timestamp to a formated date String. You can specify the date format in 'format' annotation, and the converter will format the given date for you. e.g.

 <label value="@{mydate, converter='org.zkoss.zkplus.databind.DateFormatConverter'}" self="@{format(yyyy/MM/dd)}"/>
 
If format is not given, default to 'MM/dd/yyyy'.

Since:
3.0.9
Author:
Henri Chen

Field Summary
 
Fields inherited from interface org.zkoss.zkplus.databind.TypeConverter
IGNORE
 
Constructor Summary
DateFormatConverter()
           
 
Method Summary
 java.lang.Object coerceToBean(java.lang.Object val, Component comp)
          Convert an value object to bean property type.
 java.lang.Object coerceToUi(java.lang.Object val, Component comp)
          Depending whether the data is coming from the database or coming from the datebox we might be passed either a java.util.Date or a java.sql.Timestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatConverter

public DateFormatConverter()
Method Detail

coerceToBean

public java.lang.Object coerceToBean(java.lang.Object val,
                                     Component comp)
Description copied from interface: TypeConverter
Convert an value object to bean property type.

Specified by:
coerceToBean in interface TypeConverter
Parameters:
val - the object to be coerced to backend bean property type.
comp - associated component
Returns:
the converted value suitable for assigning into backend bean property; or TypeConverter.IGNORE if you want DataBinder to ignore the assignment.

coerceToUi

public java.lang.Object coerceToUi(java.lang.Object val,
                                   Component comp)
Depending whether the data is coming from the database or coming from the datebox we might be passed either a java.util.Date or a java.sql.Timestamp

Specified by:
coerceToUi in interface TypeConverter
Parameters:
val - the object to be coerced to UI component attribute type.
comp - associated component
Returns:
the converted value suitable for assigning into UI component attribute; or TypeConverter.IGNORE if you want DataBinder to ignore the assignment.
See Also:
TypeConverter.coerceToUi(java.lang.Object, org.zkoss.zk.ui.Component)


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo