0

I'm looking for a taglib to use for calculating how many seconds there was between two dates.

heldt
  • 4,166
  • 7
  • 39
  • 67

1 Answers1

1

You just do that with EL:

<jsp:useBean id="now1" class="java.util.Date" />
<jsp:useBean id="now2" class="java.utli.Date" />
The difference is: ${now1.time/1000) - (now2.time/1000)}

That's just a simple compilable example -- in real life, the two dates would hold different values.

Vik David
  • 3,640
  • 4
  • 21
  • 29
  • I didn't use this solution, wrote my own taglib instead. But this is an alternative and working. – heldt May 17 '11 at 10:36
  • Sorry, I know this is an ancient question, but how would I go about creating the Date object from an existing value? – christopher Jul 29 '13 at 13:15
  • 1
    You can use formatDate and parseDate from the JSTL core library. See this answer: http://stackoverflow.com/questions/75489/formatting-a-long-timestamp-into-a-date-with-jstl – Vik David Jul 29 '13 at 14:02