Eu uso esta classe para trabalhar com valores double...
se alguem achar interessante pode usa-la
se alguem tiver uma maneira melhor... aceito sugestoes...
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package objetos;
import java.text.DecimalFormat;
/**
*
* @author Admin
*/
public class TruncarValor {
public static double Truncar(double valor,int qtddec) {
DecimalFormat df = new DecimalFormat();
df.applyPattern("0."+String.format("%"+(qtddec+1)+"s","").replaceAll(" ","0"));
String s = df.format(valor);
s = s.substring(0, s.length()-1).replaceAll(",", ".");
return Double.parseDouble(s);
}
public static void main (String[] args) {
System.out.println(TruncarValor.Truncar(100.129, 2));
}
}