File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts bean:write tag with format key

 
Raj Moti
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Is it possible to specify something like this
<bean:write name="entity" property="kokiStart" format='MM/dd/yyyy' />
where "kokiStart" is string from "entity" bean.
I want to get output like 12/31/2005
If this is not possible then is there any way by which I can convert any string to the format I want say date or currency.
I am using struts 1.1

Regards
Raj
 
michelle Wang
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the format of Date, I have same pbm as you, I can't find any way to solve it using struts's function. So I write my own DateUtil class to convert string to date, date to String these functions, so can used by the whole project.

And for the currency format, you can check with java API, I use this in JSP, note that the currency will change with your computer currency setting:

<%
NumberFormat currency = NumberFormat.getCurrencyInstance();
double totalAmount= invoiceObj.getTotalAmount();
%>
....
..
<td>Total:</td>
<td>USD</td>
<td><%=currency.format(totalAmount)%>
</td>
[ November 21, 2005: Message edited by: michelle Wang ]
 
Raj Moti
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks wang.
I will try to overload the bean:write tag with attribute something like charformat or stringformat.
What say ???
 
michelle Wang
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me, I use String to display Date on JSP, bcs String is more easy for you to set the display format.
 
Srinivas Rao
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj,

Over loading the default behaviour with another attribute is best choice and we are doing the same.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic