This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regd. NumberFormat  RSS feed

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to format the double number in Italian format.When i trying the following code, its truncating the decimal fields. But i want same decimal points after formating. How to get it..?

Code:


Output:
123.456.789.012,123

Expected output:
123.456.789.012,12345678

Thanks in advance.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That may not be possible with NumberFormat. You could therefore use
java.util.formatter
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html
 
Marshal
Posts: 58378
178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That format may not be possible at all. A double number only has approx 15 sig fig precision, and the number you want to print out has 20 sig fig. You are losing 5 digits which the language cannot calculate.
I have never used the java.math.BigDecimal class, but it might be a useful "first port of call."

CR
[ April 25, 2006: Message edited by: Campbell Ritchie ]
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i tryed this but i getting the ans 123.456.789.012,12346 . i dont know whay the remaining is not comming . if any one knows it let me know too
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!