I have a String representing a number (e.g. 1234.56) and a String representing a format (e.g. 1,234.56 or 1 234.56 or 1234,56...) and need to format the number String according to the format String. Both Strings are given.
Some code for better underdstanding:
public static void main(String[] args) {
String number = "1000.0";
formatNumber(number, "1,234.56"); //Should be 1,000.00
formatNumber(number, "1 234.56"); //Should be 1 000.00
formatNumber(number, "1234,56"); //Should be 1000,00
}
public static String formatNumber(String number, String format) {
return ???
}
Whats the best way to achieve that?
Thanks Paul