File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Formatting display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Formatting display" Watch "Formatting display" New topic

Formatting display

Richard Mendoza
Ranch Hand

Joined: Feb 26, 2003
Posts: 48
I have displayed a value in my textfield of type double. I want to format the display into two decimal places. What method should I use?
Ajay Singhal
Ranch Hand

Joined: Jan 10, 2001
Posts: 37
You can use NumberFormat class to get your results.
Tom Wallace

Joined: Oct 05, 2003
Posts: 1
Specifically, I'd try NumberFormat's setMaximumFractionDigits method:
double d = .25120;

NumberFormat f = NumberFormat.getInstance();


I agree. Here's the link:
subject: Formatting display
It's not a secret anymore!