I am trying to check if a string (filter) is contained in another string (formattedAmount), that is, it filters the substring formattedAmount.
I couldn't get it to work, so I just changed the code to use "equals ()" instead of "indexOf ()", just for easy testing. The equals method does not work as I would expect.
Here is a dummy script I wrote that replicates what I'm trying to do:
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Locale;
public class utils
{
public utils()
{
}
public static void main(String[] args) throws Exception
{
String filter = "333 333,44";
Number amount = new BigDecimal(333333.44);
NumberFormat nf = NumberFormat.getNumberInstance(Locale.FRANCE);
nf.setMinimumFractionDigits(2);
String formattedAmount = nf.format(amount);
if (formattedAmount.equals(filter))
{
System.out.println("Working");
}
}
}
Any ideas why it is not included in the If statement?
thank
source
share