Save This Page
Home » displaytag-1.1.1-src » org » displaytag » sample » [javadoc | source]
    1   /**
    2    * Licensed under the Artistic License; you may not use this file
    3    * except in compliance with the License.
    4    * You may obtain a copy of the License at
    5    *
    6    *      http://displaytag.sourceforge.net/license.html
    7    *
    8    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
    9    * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   10    * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   11    */
   12   package org.displaytag.sample;
   13   
   14   import java.util.Date;
   15   
   16   import javax.servlet.jsp.PageContext;
   17   
   18   import org.apache.commons.lang.time.FastDateFormat;
   19   import org.displaytag.decorator.DisplaytagColumnDecorator;
   20   import org.displaytag.exception.DecoratorException;
   21   import org.displaytag.properties.MediaTypeEnum;
   22   
   23   
   24   /**
   25    * Simple column decorator which formats a date.
   26    * @author epesh
   27    * @author Fabrizio Giustina
   28    * @version $Revision$ ($Author$)
   29    */
   30   public class LongDateWrapper implements DisplaytagColumnDecorator
   31   {
   32   
   33       /**
   34        * FastDateFormat used to format the date object.
   35        */
   36       private FastDateFormat dateFormat = FastDateFormat.getInstance("MM/dd/yyyy HH:mm:ss"); //$NON-NLS-1$
   37   
   38       /**
   39        * transform the given object into a String representation. The object is supposed to be a date.
   40        * @see org.displaytag.decorator.DisplaytagColumnDecorator#decorate(Object, PageContext, MediaTypeEnum)
   41        */
   42       public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media) throws DecoratorException
   43       {
   44           Date date = (Date) columnValue;
   45           return this.dateFormat.format(date);
   46       }
   47   }

Save This Page
Home » displaytag-1.1.1-src » org » displaytag » sample » [javadoc | source]