fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.text.DecimalFormat;
  8. import java.text.DecimalFormatSymbols;
  9. import java.text.NumberFormat;
  10.  
  11. /* Name of the class has to be "Main" only if the class is public. */
  12. class Ideone
  13. {
  14. public static void main (String[] args) throws java.lang.Exception
  15. {NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.US);
  16. Number amountText = numberFormat.parse("0.1234534532");
  17. DecimalFormat df = new DecimalFormat("#0.00", new DecimalFormatSymbols(Locale.ENGLISH));
  18. System.out.println(df.format(amountText));
  19. }
  20. }
Runtime error #stdin #stdout #stderr 0.06s 711680KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.text.ParseException: Unparseable number: "0.1234534532"
	at java.text.NumberFormat.parse(NumberFormat.java:385)
	at Ideone.main(Main.java:16)