You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nuggihalli,Naren" <Na...@gartner.com> on 2004/04/01 20:03:36 UTC
Date comparison
Does any one has Date Tool for VTL, please let me know
-----Original Message-----
From: Mike Kienenberger [mailto:mkienenb@alaska.net]
Sent: Thursday, April 01, 2004 12:27 PM
To: Velocity Developers List
Cc: Velocity Developers List
Subject: Re: DAte comparison
"Nuggihalli,Naren" <Na...@gartner.com> wrote:
> Can any one help me comapre dates
>
>
> I want something like this
>
> #if $asset.getDateAttribute("Date", ,"dd MM yyyy") <= ("02042004")
>
> Nice and cool
>
> #end
Your best bet is to write a date comparison tool rather than try to do this
at the template level.
DateTool might already do this.
If not, it should be simple enough to write a date comparision tool.
-Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
Re: Date comparison
Posted by Mike Kienenberger <mk...@alaska.net>.
Christoph Reck <ap...@recks.org> wrote:
> Nuggihalli,Naren wrote:
> > Does any one has Date Tool for VTL, please let me know
>
> See one source at:
>
>
http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/rupert/src/java/org/apache/commons/rupert/christoph/IsoDateTool.java?rev=HEAD
Or you can just use the one that ships with Velocity-Tools.
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/DateTool.html
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
Re: Date comparison
Posted by Christoph Reck <ap...@recks.org>.
Nuggihalli,Naren wrote:
> Does any one has Date Tool for VTL, please let me know
See one source at:
http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/rupert/src/java/org/apache/commons/rupert/christoph/IsoDateTool.java?rev=HEAD
I don't know if this hase been pulled over into one of the
other Jakarta-Commons sub-projects. See also:
http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/lang/CalendarUtils.java?rev=HEAD
and especially:
http://cvs.apache.org/viewcvs.cgi/jakarta-commons/lang/src/java/org/apache/commons/lang/time/
Please note that Velocity and Vel-Tools use just plain
(instantiable) java classes put into context. The
VVS ToolboxManager makes it easy to add one via
configuration.
Use it like:
In Java (or VVS config):
context.put("Date", new IsoDateTool() );
In the template:
## comparing strings:
#if( $Date.format() == "05042004" )Groovy!#end
## compare milliseconds:
#if( $asset.getDateAttribute() <= $Date.fromString("20040405").getTime() )
Bang!
#end
But beware of whatever yoour $asset tool does!
Hope this helps,
Christoph
>
> -----Original Message-----
> From: Mike Kienenberger [mailto:mkienenb@alaska.net]
> Sent: Thursday, April 01, 2004 12:27 PM
> To: Velocity Developers List
> Cc: Velocity Developers List
> Subject: Re: DAte comparison
>
>
> "Nuggihalli,Naren" <Na...@gartner.com> wrote:
>
>>Can any one help me comapre dates
>>
>>
>>I want something like this
>>
>>#if $asset.getDateAttribute("Date", ,"dd MM yyyy") <= ("02042004")
Ugh, that syntax will make nay parser bark.
>>
>>Nice and cool
>>
>>#end
>
>
> Your best bet is to write a date comparison tool rather than try to do this
> at the template level.
>
> DateTool might already do this.
>
> If not, it should be simple enough to write a date comparision tool.
>
> -Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org