Re: Velocity EOGenerator Date In Templates

From: Michael Hast (mhas..esertsky.com)
Date: Fri Mar 07 2008 - 20:40:07 EST

  • Next message: Jeremy Matthews: "Installer rev 5"

    I see, so there was no "date" in the eogen template context. Ok, as far
    as I can tell from the Velocity documentation, I would suggest to use
    the Velocity DateTool object to format dates. They suggest to use $date
    as the variable.

      Example of formatting the "current" date:
       $date -> Oct 19, 2003 9:54:50 PM
       $date.long -> October 19, 2003 9:54:50 PM PDT
       $date.medium_time -> 9:54:50 PM
       $date.full_date -> Sunday, October 19, 2003
       $date.get('default','short') -> Oct 19, 2003 9:54 PM
       $date.get('yyyy-M-d H:m:s') -> 2003-10-19 21:54:50

    Links I found for DateTool:
    http://www.jajakarta.org/velocity/tools/velocity-tools-1.1/docs/generic/DateTool.html
    http://velocity.apache.org/tools/releases/1.3/javadoc/org/apache/velocity/tools/generic/DateTool.html
    http://www.java2s.com/Code/Java/Velocity/HowtouseDateinVelocity.htm

    Michael.

    Mike Schrag wrote:
    > I have committed a new "date" (new Date()) and "calendar"
    > (Calendar.getInstance()) binding into the eogen template context. Not
    > sure how to format that in velocity, though.
    >
    > ms
    >
    > On Mar 6, 2008, at 9:55 PM, Michael Hast wrote:
    >
    >> Hi:
    >>
    >> The old EOGenerator templates had the ability of displaying date
    >> information in different formats, e.g. "<$date %a %b %d %Y$>" or
    >> "<$date %Y$>" just for the year. How would I do that in the new
    >> Velocity templates? It seems that the context needs to have a date
    >> variable passed in. Is that something that can be done?
    >>
    >> Michael.
    >> --
    >> Tel: (520) 572-9410
    >> Desert Sky Software: www.desertsky.com
    >> Specializing in the Development and Hosting of
    >> e-Business Applications.
    >



    This archive was generated by hypermail 2.0.0 : Fri Mar 07 2008 - 20:41:53 EST