Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Display string value in s:date tag  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
We migrated from struts 2.0 to 2.5.5.
In 2.0 we were able to display string value in s:date.
for example <s:date name="%{new java.util.Date(planedVisitDate)}" format="mm-dd-yyyy" />
Here planedVisitDate is a String property in Person class(private String planedVisitDate)

After migrating to 2.5.5, we could not able to display the value. Any solution will helps us a lot.
Thanks in advance.
Ramprasad
 
Bartender
Posts: 9490
12
Linux Mac OS X Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let us know if you have posted the same question to other forums.  We don't want to duplicate effort or waste others' time. 
I'm not sure why it would work in 2 and not 2.5.  My wild guess is that the Date constructor is failing (you should see an exception if this is the case). 
Given that the Date constructor that takes a String has been deprecated since Java 1.1, I wouldn't use it.  I'd either use DateFormat.parse in place of it or create a method in Person that returns a Date object. Personally, I'd prefer the latter to keep Java code out of the JSP.
 
ram prasadvarma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response.
We don't know struts has removed support for deprecated API.
 
Joe Ess
Bartender
Posts: 9490
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ram prasadvarma wrote:
We don't know struts has removed support for deprecated API.



Struts didn't remove anything.  The Java API has the deprecated method.  I said in my post that I'm not sure what's going on, but my first step in solving it would be to use supported methods.
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!