• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts bean:write tag with format key

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raj,

Over loading the default behaviour with another attribute is best choice and we are doing the same.
 
reply
    Bookmark Topic Watch Topic
  • New Topic