Thank you all for your inputs.
Number of years back a scientist (theoretical mathematician & himself a FORTRAN programmer was working on Cray Super Computer at UCLA, Los Angeles & Jet Propulsion Lab (JPL)) working on a classified project
asked me (a junior computer programmer at that time) for such a function.
I wrote using Microsoft Quick C compiler. I was not told what the application was.
Recently, I read the following information about Java language feature:
https://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html
If you want a DecimalFormat object for a nondefault Locale,
you instantiate a NumberFormat and then cast it to DecimalFormat.
Here's an example:
NumberFormat nf = NumberFormat.getNumberInstance(loc);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern(pattern);
String output = df.format(value);
System.out.println(pattern + " " + output + " " + loc.toString());
Running the previous code example results in the output that follows.
The formatted number, which is in the second column, varies with Locale:
###,###.### 123,456.789 en_US
###,###.### 123.456,789 de_DE
###,###.### 123 456,789 fr_FR
Below link has some information about grouping:
https://en.wikipedia.org/wiki/Decimal_mark
Above link has the following sentence:
In some countries,
these "digit group separators" are only employed to the left of the decimal mark;
in others, they are also used to separate numbers with a long fractional part.