Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2015075 | 1.2.0 | Brian Beck | P2 | Resolved | Fixed | 1.2beta3 |
Shouldn't the following code work? It does under 1.1, but 1.1.1 throws
an exception.
import java.text.NumberFormat;
public class CurrTest {
public static void main(String args[]) {
double testnum = 345.6789;
long longnum = 23234567;
try {
NumberFormat cf = NumberFormat.getCurrencyInstance();
System.out.println("cf: " + cf);
Number tnum = cf.parse("$0.00");
System.out.println("tnum: " + tnum);
String result = new Double(tnum.doubleValue()).toString();
System.out.println("result: " + result);
} catch(Exception e) {
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}
try {
NumberFormat cf = NumberFormat.getNumberInstance();
System.out.println("cf: " + cf);
Number tnum = cf.parse("0.00");
System.out.println("tnum: " + tnum);
String result = new Double(tnum.doubleValue()).toString();
System.out.println("result: " + result);
} catch(Exception e) {
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}
}
}
an exception.
import java.text.NumberFormat;
public class CurrTest {
public static void main(String args[]) {
double testnum = 345.6789;
long longnum = 23234567;
try {
NumberFormat cf = NumberFormat.getCurrencyInstance();
System.out.println("cf: " + cf);
Number tnum = cf.parse("$0.00");
System.out.println("tnum: " + tnum);
String result = new Double(tnum.doubleValue()).toString();
System.out.println("result: " + result);
} catch(Exception e) {
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}
try {
NumberFormat cf = NumberFormat.getNumberInstance();
System.out.println("cf: " + cf);
Number tnum = cf.parse("0.00");
System.out.println("tnum: " + tnum);
String result = new Double(tnum.doubleValue()).toString();
System.out.println("result: " + result);
} catch(Exception e) {
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}
}
}
- backported by
-
JDK-2015075 NumberFormat parse throws exceptions on 0
- Resolved
- duplicates
-
JDK-4042402 SimpleDateFormat: parser crashes if hh, mm, or ss is zero
- Closed
-
JDK-4048969 NumberFormat parse ignores leading zeros in the fractional part
- Closed
-
JDK-4055250 The parse method in SimpleDateFormat causes a NullPointerException
- Closed