Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / altoslib / AltosParse.java
index 2fb69c15ce40de247537c22377f422d15afcbf18..de79c2fb16a7b6dbb9703c29ca72ca4d804bdd86 100644 (file)
@@ -15,8 +15,9 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib_6;
+package org.altusmetrum.altoslib_7;
 
+import java.util.*;
 import java.text.*;
 
 public class AltosParse {
@@ -40,11 +41,23 @@ public class AltosParse {
                }
        }
 
-       public static double parse_double(String v) throws ParseException {
+       static NumberFormat nf_locale = NumberFormat.getInstance();
+
+       static NumberFormat nf_net = NumberFormat.getInstance(Locale.ROOT);
+
+       public static double parse_double_locale(String str) throws ParseException {
                try {
-                       return Double.parseDouble(v);
-               } catch (NumberFormatException e) {
-                       throw new ParseException("error parsing double " + v, 0);
+                       return nf_locale.parse(str.trim()).doubleValue();
+               } catch (ParseException pe) {
+                       throw new ParseException("error parsing double " + str, 0);
+               }
+       }
+
+       public static double parse_double_net(String str) throws ParseException {
+               try {
+                       return nf_net.parse(str.trim()).doubleValue();
+               } catch (ParseException pe) {
+                       throw new ParseException("error parsing double " + str, 0);
                }
        }