Skip to content

Commit

Permalink
Forces double conversions in Locale.US
Browse files Browse the repository at this point in the history
This avoids unparsable strings in Double.parseDouble when numbers
are converted into non-latin characters (under an Arabic locale
for example).

Fixes #1181
charlesfleche committed Dec 17, 2015
1 parent 698c3e9 commit 1eb322c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
package org.odk.collect.android.widgets;

import java.text.NumberFormat;
import java.util.Locale;

import org.javarosa.core.model.data.DecimalData;
import org.javarosa.core.model.data.IAnswerData;
@@ -70,7 +71,7 @@ public DecimalWidget(Context context, FormEntryPrompt prompt, boolean readOnlyOv

Double d = getDoubleAnswerValue();

NumberFormat nf = NumberFormat.getNumberInstance();
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
nf.setMaximumFractionDigits(15);
nf.setMaximumIntegerDigits(15);
nf.setGroupingUsed(false);

0 comments on commit 1eb322c

Please sign in to comment.