2008-04-02

DecimalFormat处理科学计数法

关键字: 科学计数法
import java.text.DecimalFormat;

public class Test {
	private double j=10000.2252 * 1000000000.25145* 1000000000.25145;

	public static void main(String args[]) {
		Test test = new Test();
		System.out.println(test.j);
		String hehe = test.SicenToComm(test.j);
		System.out.println(hehe);
	}

	// 解决科学技术法的问题,四舍五入保留两位小数
	public String SicenToComm(double value) {
		String retValue = null;
		DecimalFormat df = new DecimalFormat();
		df.setMinimumFractionDigits(2);
		df.setMaximumFractionDigits(2);
		retValue = df.format(value);
		System.out.println(retValue);
		retValue = retValue.replaceAll(",","");
		return retValue;
	}
}
评论
发表评论

您还没有登录,请登录后发表评论

Terry_Y
搜索本博客
最近加入圈子
最新评论