java-faker icon indicating copy to clipboard operation
java-faker copied to clipboard

Use the locale in String.formtat()

Open armandomonteiroptc opened this issue 6 years ago • 1 comments

Describe the bug The string format should benefit from the Faker locale (Locale.ENGLISH by default), otherwise a formatted string like the longitude or latitude, can be 1.234567 or 1,234567 depending in the Locale.

To Reproduce

Using a String.format("%.8g", (faker.random().nextDouble() * 180) - 90);

  • depends on external JVM configuration
    • if Locale PT then 1,234567.

Using a String.format(Locale.ENGLISH, "%.8g", (faker.random().nextDouble() * 180) - 90);

  • controlled by the application
    • then 1.234567.

String.format()

Expected behavior String.format(Locale.ENGLISH, "%.8g", (faker.random().nextDouble() * 180) - 90);

  • controlled by the application
    • then 1.234567.

Versions:

  • OS: Any
  • JDK: Any
  • Faker Version: using 0.18 - however the implementation seems to be the same in the last version

Additional context

armandomonteiroptc avatar Sep 26 '19 10:09 armandomonteiroptc

Yes we have the same problem. Locale ignored for String.format().

maxtar avatar Apr 22 '20 12:04 maxtar