A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
Formatting display
Richard Mendoza
Ranch Hand
Joined: Feb 26, 2003
Posts: 48
posted
Oct 05, 2003 21:42:00
0
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
posted
Oct 05, 2003 22:49:00
0
Hi,
You can use
NumberFormat
class to get your results.
Ajay
Tom Wallace
Greenhorn
Joined: Oct 05, 2003
Posts: 1
posted
Oct 05, 2003 22:55:00
0
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
Similar Threads
representing exponents like x to the power 2 3 and so on
random display of data ?
How to hide addressbar and toolbar of IE using Javascript?
how to call url
Session expiration in struts using nested tags
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter