Hi all,

The below snippet displays the result as not equals instead of equals


        String s = "11 567 747,18 €";
        String s1 = s.replaceAll(" ","");
        String s2 = s1.replaceAll("€","");
        String s3 = s2.replaceAll(",",".");

        String pattern = "# ###,##.##¤";
        DecimalFormat df = (DecimalFormat)NumberFormat.getNumberInstance(Locale.FRANCE);
        df.applyPattern(pattern);
        df.setGroupingSize(3);
        String format = df.format(11567747.18);
        System.out.println(format);
        System.out.println(s);

        if(s.equals(format))
            System.out.println("equlas");
        
        else
            System.out.println("not equlas");

Output:

11 567 747,18 €
11 567 747,18 €not equlas

could anyone please help me to sort it out?
I tried checking equality of individual chars, it displays not equals in the in the blankspace place after 11 and 567

Views: 77

Reply to This

Replies to This Discussion

Hi,

I ran your code snippet in https://ideone.com/ with the required imports and class and main method and got the following output.

11,567,747.18 EUR

11 567 747,18 €

not equlas

Hope that helps,

Cheers,

Martin

Hi Martin,

   Thank you so much. I sorted it out.

RSS

Adverts

© 2017   Created by Rosie Sherry.   Powered by

Badges  |  Report an Issue  |  Terms of Service