velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damian Gajda <dga...@ngo.pl>
Subject Re: how to compare the time in Velocity?
Date Mon, 02 Sep 2002 13:17:21 GMT
W liƛcie z pon, 02-09-2002, godz. 14:57, Geir Magnusson Jr. pisze: 
> On 9/1/02 11:00 PM, "James Wang" <touchmyheart10000@yahoo.com> wrote:
> 
> > i got two time objects from  velocity template,and
> > i want to compare them in velocity,what can i do?
> > it seem i cant do such things!
> > do i have to compare it in Modules part in MVC?
> > 
> 
> Well, it depends on what kind of time objects.  The java.util.Date class has
> a getTime() method, but those return longs (and Vel doesn't do longs).
> 
> The best bet is to add a compare function to the time class or a comparison
> tool into the context

java.util.Date has also a compareTo(Date) method. The following should
be enough:

#set($result = $time1.compareTo($time2))
#if($result == 0)
equal
#elseif($result < 0)
time1 is before time2
#else
time2 is before time1
#end

Take care,
-- 
Damian Gajda
Web Application Design and Consultancy
dgajda@ngo.pl
mobile +48 501 032 506



--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message