fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.text.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. // your code goes here
  14. String a = "1.21";
  15. System.out.println(a);
  16.  
  17. otherSymbols.setDecimalSeparator(',');
  18. otherSymbols.setGroupingSeparator('.');
  19. DecimalFormat df = new DecimalFormat("#.#", otherSymbols);
  20.  
  21. Double returnValue = Double.valueOf(df.format("4.75"));
  22.  
  23. System.out.println(String.valueOf(returnValue));
  24. }
  25. }
Runtime error #stdin #stdout #stderr 0.13s 321216KB
stdin
Standard input is empty
stdout
1.21
stderr
Exception in thread "main" java.lang.IllegalArgumentException: Cannot format given Object as a Number
	at java.text.DecimalFormat.format(DecimalFormat.java:507)
	at java.text.Format.format(Format.java:157)
	at Ideone.main(Main.java:22)