Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display table with decimal values like 0.2 problem

 
vijay jamadade
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I have a display table. In that i am printing the decimal values like 0.2, 0.3 etc. But the values get printed like .2,.3 only not 0.2,0.3.

that means the 0 is not getting displayed before the decimal point.
Tell me what to do if i want to display the zero also.

Thanks in advance.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How you print those values , in your JSP, Post that code.

If you populated this values in bean, then at action class format them using DecimalFormat class and then store into bean.

HTH
 
vijay jamadade
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply sagar,
The problem is in my action class also the value is coming as '.2'
and I want it as '0.2' where should i handle it. in query or in
action class. the class you were talking about is formatting of numbers.
I am not getting. Can you send me some sample line code how can
i achieve this?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code, showing How you displaying them in JSP page with Action class, from where they are originating ??
 
vijay jamadade
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the values are originating in the result of the select query.
that means in resultset the '.2' like values are there. So I think i should
handle it in query itself. Do you have any idea how it can be handled in query
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vijay jamadade:

that means in resultset the '.2' like values are there.


What is the data type of column which stores values like, .2 , .3 etc..

If its varchar, then parse the string and store into double, then there is no requirement of formatting it.
 
vijay jamadade
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya exactly that was the problem. Thanks.
I was storing the values in string thats why it was taking so.
now i am using float and its working fine. silly mistake.
Thanks once again.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic