Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes Trim in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trim in java" Watch "Trim in java" New topic

Trim in java

rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
I am getting a result from java file which is of type double.When displaying this number through jsp file i want only 2 digits to appear after decimal point.
Pls help
Benny Tang

Joined: Aug 03, 2003
Posts: 26
You can use the method setMaximumFractionDigit() in java.text.NumberFormat to manipulate the format of the number.
Benny T
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

This really has nothing to do with JSPs, so I'm moving it along to Java In General (Beginner).

[Asking smart questions] [About Bear] [Books by Bear]
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Can anyone tell me exactly how to do this?
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Check the API docs for DecimalFormat and NumberFormat

I agree. Here's the link:
subject: Trim in java
jQuery in Action, 3rd edition