This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Formatting display
It's not a secret anymore!