Java tutorial
//package com.java2s; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.text.ParseException; public class Main { public static boolean isMatchingThresholdEqual(int thresholdValue, String percentString) throws ParseException { if (percentString == null) { return false; } int intVal = getMatchingThresholdFromString(percentString); return (intVal == thresholdValue); } public static int getMatchingThresholdFromString(String value) throws ParseException { char percent = new DecimalFormatSymbols().getPercent(); value = value.replace(percent, ' '); Number number = NumberFormat.getNumberInstance().parse(value); double parse = number.doubleValue(); double p = Math.log10(Math.max(Double.MIN_VALUE, Math.min(1, parse / 100))); return Math.max(0, (int) Math.round(-12 * p)); } }