把Float数转换为String,用StringTokener找到'.'的位置,取出"."后面的数判断是否为两位!
解决方案 »
- 导入EXCEL文件时的问题
- firefox js来管理cookie
- JSP开发环境配置问题
- 有人在抵制北京奥运,投票去
- fusionchart v3导出pdf
- JSTL中<c:forEach中如何得到循环的索引?就是相当于for中的i?
- Error #: 101 : invalid escape character
- 我在JAVABEAN监听局域网服务器 随时得到流 ,当…………
- struts(<html:select>方面的问题)
- 暴急!在Servlet中,用CallableStatement怎么调用Oracl9i中的函数,在线等,灌水不用进了
- 开放源码的jsp/servlet(MVC)论坛系统:雷霆论坛
- javax.servlet.*在哪?
1:float * 100
2:然后截去小数点后的东西
3:再除100
4:和原来数字比较大小
System.out.println(2==Double.toString(x).lastIndexOf('.'));
Double d=12355.3555
System.out.println(2==Double.toString(d).lastIndexOf('.'));
还算简单吧
{
public String customFormat(String pattern,double value)
{
try
{
DecimalFormat decFormatter = new DecimalFormat (pattern);
String result = decFormatter.format(value);
return result;
}
catch(Exception e)
{
return e.toString();
}
}
}jsp
<jsp:useBean id = "numFormat" scope = "page" class = "format.DecimalFormatNum"/>
<%=numFormat.customFormat("##.##",你的数字)%>