# "%.2f" format problem

String fmt = "%.2f";
outfile.write(String.format(fmt, point.core_dist));

I have got a problem. Using this format it prints out 2,0 and what I want to achieve is a decimal point so 2.0 How to solve that?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
It is eaiser to use DecimalFormat for formatting than printf.
This is the simple example:
http://www.roseindia.net/java/beginners/DecimalFormatExample.shtml

Commented:
This should give you what you want:

NumberFormat formatter = new DecimalFormat("#0.0");
outfile.write(formatter.format(point.core_dist));

Author Commented:
It didn't help. Still writing a colon instead of decimal point. Any other suggestions?
Even if i do this  System.out.println(formatter.format(2.0)); it prints out 2,0 in the console instead of 2.0
Commented:
What if you just print
System.out.println("2.0")

or another test

double dd = 2.05;

System.out.println("" + dd);

Do all these print comma istead of dot ?
Author Commented:
yep they both print decimal point

This code:

NumberFormat formatter = new DecimalFormat("#0.0");
System.out.println(formatter.format(2.0));

System.out.println("2.0");
double dd = 2.05;
System.out.println("" + dd);

Gives the following results:
2,0
2.0
2.05
Commented:
That is probably something wrong with locale
Author Commented:
what do you mean by that?
Commented:

Try this way:
Locale.setDefault(Locale.US);
NumberFormat formatter = new DecimalFormat("#0.0");
System.out.println(formatter.format(2.0));

Experts Exchange Solution brought to you by