File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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?
Richard
Ajay Singhal
Ranch Hand

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

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

NumberFormat f = NumberFormat.getInstance();

f.setMaximumFractionDigits(2);

System.out.println(f.format(d));
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Formatting display