File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Display table with decimal values like 0.2 problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Display table with decimal values like 0.2 problem" Watch "Display table with decimal values like 0.2 problem" New topic
Author

Display table with decimal values like 0.2 problem

vijay jamadade
Ranch Hand

Joined: May 12, 2008
Posts: 240
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.


Regards, Vijay Jamadade.
( Nothing is Impossible.)
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
vijay jamadade
Ranch Hand

Joined: May 12, 2008
Posts: 240
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: May 12, 2008
Posts: 240
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: May 12, 2008
Posts: 240
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

You are welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display table with decimal values like 0.2 problem