Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

casting double to int while using el  RSS feed

 
muktesh tripathi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to show the result of calculation (which is done by a bean) in a JSP using el.
The problem is that I have to show the same result as double,int and may be some format like 2,00,000 .
1.Is there a way to kind of cast output while using el??
2. El is used to display the result of expression.. Can it be used to get a value from bean method and than store the value to some variable?? If yes then please tell how??

Scenario: ${mybean.amount} returns 45678987.5645674 i want it to print something like 4,56,78,988.
I don't want to bother bean method to do that for me..as first output is also required to be displayed..

I ask forgiveness in advance if the question is too silly..
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You normally use JSTL´s fmt taglib for this.

But I see that you need to format it in Rupee´s decimal format. It has two patterns and thus you cannot use the standard NumberFormat classes for this (which is also backed by fmt taglib) as it accepts only one pattern. You need to write some utility method which converts it to the desired String. If you Google smart, you can find a lot of examples.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!