fork(1) download
  1. import java.text.*;
  2. import java.util.Locale;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) throws ParseException {
  7.  
  8. final String text = "1,2,3";
  9. final int weirdResult = 123;
  10.  
  11. final NumberFormat usDecimalFormat = DecimalFormat.getNumberInstance(Locale.US);
  12. final Number parsedNumber = usDecimalFormat.parse(text);
  13.  
  14. if(parsedNumber.doubleValue() == weirdResult){
  15. System.out.println(text + " is bizarrely parsed as " + weirdResult);
  16. } else {
  17. System.out.println(text + " is parsed as " + parsedNumber);
  18. }
  19. }
  20. }
  21.  
Success #stdin #stdout 0.11s 52300KB
stdin
Standard input is empty
stdout
1,2,3 is bizarrely parsed as 123