Class CustomDateConverter

java.lang.Object
io.jans.casa.ui.CustomDateConverter
All Implemented Interfaces:
org.zkoss.bind.Converter

public class CustomDateConverter extends Object implements org.zkoss.bind.Converter
This class is a custom ZK converter employed to display dates appropriately according to user location. It uses the time offset with respect to UTC time and a formatting pattern supplied to show dates. It does not implement String to Date conversion.
Author:
jgomer
  • Field Summary

    Fields inherited from interface org.zkoss.bind.Converter

    IGNORED_VALUE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    coerceToBean(Object val, org.zkoss.zk.ui.Component comp, org.zkoss.bind.BindContext ctx)
    This method is called when converting String to Date.
    coerceToUi(Object val, org.zkoss.zk.ui.Component comp, org.zkoss.bind.BindContext ctx)
    This method is called when conversion (Date to String) is taking placing in .zul templates.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomDateConverter

      public CustomDateConverter()
  • Method Details

    • coerceToUi

      public Object coerceToUi(Object val, org.zkoss.zk.ui.Component comp, org.zkoss.bind.BindContext ctx)
      This method is called when conversion (Date to String) is taking placing in .zul templates.
      Specified by:
      coerceToUi in interface org.zkoss.bind.Converter
      Parameters:
      val - An object representing a date, namely a java.util.Date or a long value (milliseconds from the epoch)
      comp - The UI component associated to this converstion
      ctx - Binding context. It holds the conversion arguments: "format" and "offset" are used here
      Returns:
      A string with the date properly formatted or null if val parameter is not a valid date
    • coerceToBean

      public Object coerceToBean(Object val, org.zkoss.zk.ui.Component comp, org.zkoss.bind.BindContext ctx)
      This method is called when converting String to Date.
      Specified by:
      coerceToBean in interface org.zkoss.bind.Converter
      Parameters:
      val - A date in string form
      comp - Associated component
      ctx - Bind context for associate Binding and extra parameter (e.g. format)
      Returns:
      null (conversion not implemented)