aspose file tools
The moose likes Java in General and the fly likes number formatted is unexpected. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "number formatted is unexpected." Watch "number formatted is unexpected." New topic
Author

number formatted is unexpected.

nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
I have a problem to make the number formatted to 2 points.
This is the code i use and i expect to get iQ = 0.13 instead of 0.133 using codes below. What is my syntax arror actually?
Could anybody tell me?

NumberFormat nf;
nf = NumberFormat.getInstance();
nf.setMaximumIntegerDigits(2);
nf.setMinimumIntegerDigits(2);

String iQ = nf.format(iQuan);
System.out.println("iQ :"+iQ);


Thanks alot.
Barry Higgins
Ranch Hand

Joined: Jun 05, 2003
Posts: 89
Try using


This sets the digits after the decimal point .. you were setting the digits before the decimal point.
Regards,
Barry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: number formatted is unexpected.
 
Similar Threads
Number Format Specifiers
java.lang.NumberFormatException: For input string: ""
NumberFormat help!
comparing strings
Double and format?