10 Replies Latest reply on Jan 10, 2007 6:46 PM by 807599

    problem converting double to string

    807599
      Hello.
      I try to fix double to format: ##.### in jTable but i have problem. In my country we use ,(comma) instead of . (point) and in jTable I need . (point) so i write sth like this to write numbers in jTable:
      double all = Double.parseDouble(s1.toString())+Double.parseDouble(s2.toString());
                        
                        
                        try{
                        String fmt = "##.###";
                        String tmp = String.valueOf(all);
                        if(tmp.contains(","))
                        tmp = tmp.replaceAll(",",".");
                        System.out.println("TMP: "+tmp);
                        DecimalFormat df = new DecimalFormat(fmt);
                        System.out.println(df.format(tmp));
                        all = Double.parseDouble(df.format(tmp));
                        }
      catch(java.lang.IllegalArgumentException xxx)
                        {
                             System.out.println(xxx);
                        }
      where s1 and s2 are double with comma and all adding them.

      My problem is that when I trying to parse a double from "all" application catch exception.