JavadocMD / simplelatlng

A simple, lightweight library for common latitude and longitude calculation needs in Java.
89 stars 20 forks source link

localization issue on LatLng.toString() #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following JUnit fails :
Locale.setDefault(Locale.FRANCE);
assertEquals("(6.123456,45.123456)", new  LatLng(6.123456, 
45.123456).toString());

The decimal separator is localized to ','
The result is then "(6,123456,45,123456)" which is confusing.

I would suggest the following fixe on LatLngConfig:34
public static final NumberFormat DEGREE_FORMAT = new DecimalFormat(
            "0.000000", new DecimalFormatSymbols(Locale.US)); 
instead of :
public static final NumberFormat DEGREE_FORMAT = new DecimalFormat(
            "0.000000"); 

BTW: DecimalFormat.format is not thread safe, you may consider creating a new 
DecimalFormat object on each format use. 

Original issue reported on code.google.com by leo.flan...@heliorama.fr on 18 Jun 2013 at 8:50

GoogleCodeExporter commented 9 years ago
Fixed for v1.3.0. Notice this required an API change and thus is potentially 
breaking (hence 1.3.0 and not 1.2.1). LatLngConfig.DEGREE_FORMAT needed to be 
changed to ThreadLocal to fix thread safety.

Original comment by TylerCo...@gmail.com on 2 Jul 2013 at 5:17

GoogleCodeExporter commented 9 years ago

Original comment by TylerCo...@gmail.com on 2 Jul 2013 at 5:17