X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosParse.java;h=1cbddcf9ef9dfbc4c68cf7c20a6c3a5cb84b30f5;hb=4c20fdfa543059739b756171b991d430789cded1;hp=66bbeed5eb185f5b101b54a1bfad369d1fb44a0b;hpb=02d111b1b53ef01fc6e9ab6c4bc60b8af1be0067;p=fw%2Faltos diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index 66bbeed5..1cbddcf9 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -15,8 +15,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_1; +package org.altusmetrum.altoslib_10; +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); } }