Reputation: 9890
I am porting an existing application to Android, and stumbled upon the following problem. This piece of code works perfectly fine on Java SE:
String NAN_STRING = "";
DecimalFormatSymbols SYMBOLS;
SYMBOLS = new DecimalFormatSymbols();
SYMBOLS.setDecimalSeparator('.');
SYMBOLS.setNaN(NAN_STRING);
DecimalFormat format = new DecimalFormat("0.###", SYMBOLS);
double d = Double.NaN;
System.out.print("x");
System.out.print(format.format(d));
System.out.print("y");
However, on Android, I am getting a NoSuchElementException
when executing format.format(d)
:
Caused by: java.util.NoSuchElementException
at libcore.icu.NativeDecimalFormat$FieldPositionIterator.next(NativeDecimalFormat.java:564)
at libcore.icu.NativeDecimalFormat$FieldPositionIterator.setFieldPosition(NativeDecimalFormat.java:550)
at libcore.icu.NativeDecimalFormat$FieldPositionIterator.access$000(NativeDecimalFormat.java:507)
at libcore.icu.NativeDecimalFormat.formatDouble(NativeDecimalFormat.java:264)
at java.text.DecimalFormat.format(DecimalFormat.java:677)
at java.text.NumberFormat.format(NumberFormat.java:211)
at com.example.androidtestbed.MainActivity.onCreate(MainActivity.java:27)
If I replace NAN_STRING
with e.g. "NaN"
instead of ""
, it seems to work, but this is not the behaviour I desired. Am I doing something wrong or is this a bug in the Android classes?
Upvotes: 1
Views: 252
Reputation: 4665
this is not the right forum for reporting Android core library bugs. code.google.com is where where you should report Android core library bugs: https://code.google.com/p/android/issues/detail?id=59600
Upvotes: 1