my dog learned polymorphism*
The moose likes Servlets and the fly likes decimal format conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "decimal format conversion" Watch "decimal format conversion" New topic
Author

decimal format conversion

kumar m
Greenhorn

Joined: Aug 20, 2002
Posts: 13
Hi All,
In our project, the calculated tax amount is assigned to a double variable. Using the method format present in DecimalFormat class, total tax amount is rounded to 2 decimal places and assigned to a String variable.
But during execution of the program in JRun3.1 server and JDK1.2 we found JRun goes down when decimal format conversion takes place.
So please suggest any other way to round of the double value to 2 decimal places and store in a string variable.
Thank you
Regards
kumar.
Dan Richardson
Greenhorn

Joined: Aug 06, 2002
Posts: 23
Here are two ways that I can think of . . .
1).

2).
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Are you using a shared DecimalFormat object? DecimalFormat objects are not synchronized, so you shouldn't try to use them across threads.


James Carman, President<br />Carman Consulting, Inc.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Welcome to the JavaRanch! Please adjust your display name to meet
the JavaRanch Naming Policy. You can change it here.
Thanks!
and welcome to the JavaRanch!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: decimal format conversion
 
Similar Threads
Precision loss in String to Float and double to float
Arrays
decimal place formatting JtextField
Decimal formatting of
help with double