Двойное значение для округления в Java

I have a double value = 1.068879335 i want to round it up with only two decimal values like 1.07.

I tried like this

DecimalFormat df=new DecimalFormat("0.00");
String formate = df.format(value);
double finalValue = Double.parseDouble(formate) ;

this is giving me this following exception

java.lang.NumberFormatException: For input string: "1,07"
     at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
     at java.lang.Double.parseDouble(Double.java:510)

can some one tell me what is wrong with my code.

finaly i need the finalValue = 1.07;

36
задан jimmy 25 January 2011 в 17:43
поделиться