skip to Main Content

String.format("%.2f",0.333333);
gives 0,33 but I’d like to have 0.33.

2

Answers


  1. Put Locale.ROOT inside, like this:

    String.format(Locale.ROOT, "%.2f",0.333333);
    
    Login or Signup to reply.
  2. String.format() picks the locale you are in. You have to specify the locale explicitly if you want. instead of,

    You can use it like this:

    String.format(Locale.US, "%.2f", 0.333333)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search