Get your CodeRanch badge!*
The moose likes Struts and the fly likes 24-hour time format for s:date-tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "24-hour time format for s:date-tag" Watch "24-hour time format for s:date-tag" New topic
Author

24-hour time format for s:date-tag

Anders Sjurmann
Greenhorn

Joined: Apr 11, 2008
Posts: 4
Hi,
I'm having trouble geting the s ate-tag to display time as an 24-hour clock ("army time"). When I set the format="hh:mm", leaving out the a-option for AM/PM, it still displays time as a 12-hour clock. Is there any option I have missed, or is there some other way around this?

Cheers, Anders
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Hi Anders

I used JSTL format tag and it is show date in 24 hours format

<jsp:useBean id="now" class="java.util.Date" />
<fmt:formatDate pattern="HH:mm" value="${now}" />

Can you tell in which struts library is date tag present?
I mean (bean,html,logic etc).I am not able to find it anywhere in struts tag library.

Thanks
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Anders:

Use "HH:mm" with an upper case "H", rather than "hh:mm". This is explained in the JavaDoc for the SimpleDateFormat class.

Gowher:

Anders is apparently using Struts 2, which uses <s:xxx> tags in place of those used in Struts 1.


Merrill
Consultant, Sima Solutions
Anders Sjurmann
Greenhorn

Joined: Apr 11, 2008
Posts: 4
Thanks Gowher! The capital H-es did the trick. Stupid of me not to think of it really.

The date-tag is in Struts2. I guess I didn't mention that. Sorry.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 24-hour time format for s:date-tag
 
Similar Threads
Stephen Wright-isms
Stupid people in power
convert TIME to Millisec
Please help me this. Im new to this.
Strange problem in date calculation (IS IT BUG!!!)