| Author |
decimal format
|
pam rowell
Greenhorn
Joined: Jan 21, 2002
Posts: 7
|
|
|
help i need to format a real number to two decimal places and i forgot the syntax to do it i know it has something to do with decimal format or format decimal
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
Check out the Decimalformat class in java.text package
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Just in case you hadn't found it yet, Sun keeps the documentation for all classes in the standard API on-line at http://java.sun.com/j2se/1.4/docs/api/index.html. When you construct your DecimalFormat object, the pattern you probably want to use is 0.00 - like this: new DecimalFormat("0.00") Good Luck.
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
pam rowell
Greenhorn
Joined: Jan 21, 2002
Posts: 7
|
|
thanks dirk i had remembered the format DecimalFormat df = new DecimalFormat("0.00"); what i forgot was to import :roll:
|
 |
 |
|
|
subject: decimal format
|
|
|