• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP date field

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65119
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use tag <s:date... instead:

<s:date name="myDate" format="MM/dd/yy" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic