0

I have

String str = "$2,542";

I want to format this string to:

"$2,542.00"

Is it possible to achieve this with java String.format() method???

The Guest
  • 698
  • 11
  • 27
  • @ whoever marked it as duplicate: I am not asking how to format a number, I AM ASKING HOW TO FORMAT A STRING THAT HAS NUMBER.., first read the question properly. – The Guest Jan 08 '16 at 17:55
  • But you ARE asking how to format a number. Numbers have "a format" only when they are depicted as a string. – FredK Jan 08 '16 at 18:00
  • Your amount : `double amt = 123.456;`, make instance of NumberFormat like this `NumberFormat formatter = NumberFormat.getCurrencyInstance();` then format your number: `String formatted = formatter.format(amt);` – Asad Haider Jan 08 '16 at 18:29

0 Answers0