summaryrefslogtreecommitdiff
path: root/altoslib/AltosUnits.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-05-19 10:09:22 -0700
committerKeith Packard <keithp@keithp.com>2015-05-19 10:09:22 -0700
commit3e5e9333420ede74d998556c1bbd5888e8ff75ae (patch)
treedbd6e450c8352e7a1005a28f5016d95769b962d0 /altoslib/AltosUnits.java
parent3fbf0a29a1b8a67b90ef965ee3e2e972c0ec33a1 (diff)
altoslib: Expose locale and non-locale floating point parsing functions
UI bits use locale-specific floating point formats, so parsing those needs to use the locale. Network-based data, like .kml bits need to use non-locale-specific parsing code, so now we've got both APIs available, and each used as appropriate. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosUnits.java')
-rw-r--r--altoslib/AltosUnits.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java
index f6e34e77..e266b243 100644
--- a/altoslib/AltosUnits.java
+++ b/altoslib/AltosUnits.java
@@ -17,6 +17,8 @@
package org.altusmetrum.altoslib_6;
+import java.text.*;
+
public abstract class AltosUnits {
public abstract double value(double v, boolean imperial_units);
@@ -29,13 +31,22 @@ public abstract class AltosUnits {
public abstract int show_fraction(int width, boolean imperial_units);
- public double parse(String s, boolean imperial_units) throws NumberFormatException {
- double v = Double.parseDouble(s);
+ public double parse_locale(String s, boolean imperial_units) throws ParseException {
+ double v = AltosParse.parse_double_locale(s);
+ return inverse(v, imperial_units);
+ }
+
+ public double parse_net(String s, boolean imperial_units) throws ParseException {
+ double v = AltosParse.parse_double_net(s);
return inverse(v, imperial_units);
}
- public double parse(String s) throws NumberFormatException {
- return parse(s, AltosConvert.imperial_units);
+ public double parse_locale(String s) throws ParseException {
+ return parse_locale(s, AltosConvert.imperial_units);
+ }
+
+ public double parse_net(String s) throws ParseException {
+ return parse_net(s, AltosConvert.imperial_units);
}
public double value(double v) {
@@ -105,4 +116,4 @@ public abstract class AltosUnits {
public String say_units(double v) {
return say_units(v, AltosConvert.imperial_units);
}
-} \ No newline at end of file
+}