wood burning stoves 2.0*
The moose likes Struts and the fly likes JSP date field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSP date field" Watch "JSP date field" New topic
Author

JSP date field

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
In a struts JSP page, I have a Date type field. it gets value from an attribute in an Action java class. In the action class, I define it as

import java.util.Date;

private Date myDate;

public Date getMyDate() { return mydate; }
public void setMyDate(Date d) { myDate = d; }

In JSP it is like <s:label ... value="%{mydate}" />

However, on the JSP I always see the JSP display the field as "mm/dd/yy". I want it to show "mm/dd/yyyy". How can I see that with minimum change ? I post this thread in JSP instead of struts because I think it is a general JSP question.

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Not if you're using Struts tags to display it.

IIRC JSTL's <fmt:formatDate> takes an immediate pattern. If your app is I11Lized you may not want to use an immediate pattern.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
David Newton wrote:Not if you're using Struts tags to display it.

IIRC JSTL's <fmt:formatDate> takes an immediate pattern. If your app is I11Lized you may not want to use an immediate pattern.


Do you mean if I use struts 2 tag then I can not get "mm/dd/yyyy" format ??
Mike Cobelmach
Greenhorn

Joined: Jun 17, 2009
Posts: 19
Use tag <s:date... instead:

<s:date name="myDate" format="MM/dd/yy" />
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP date field