May I know how I can escape a string to be passed into decimal format?
// currencySymbolPrefix can be any string.
NumberFormat numberFormat = new DecimalFormat(currencySymbolPrefix + "#,##0.00");
How can I escape currencySymbolPrefix, so that it may contains any characters including ‘#’, and will not be interpreted as one of the pattern.
Please do not suggest
NumberFormat numberFormat = new DecimalFormat("#,##0.00");
final String output = currencySymbolPrefix + numberFormat.format(number);
as my vendor’s method only accept single NumberFormat.
You can use apostrophes to quote:
If
currencySymbolPrefixitself may contain apostrophes, you’d need to escape those by doubling them: