String 转 float 问题 String a = "1000000000";float b = Float.parseFloat(a);System.out.println(b);会输出 1.0E8我现在想输出正常的数字,怎么解决? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DecimalFormat df = new DecimalFormat("0.##");df.format(v1); you can using String#format when you use JDK1.5such as;System.out.println(String.format("%1f",b)); /** * 格式化欄位值 * @param sValue 原欄位值 * @param cType 欄位數據類型 * @return 整理後的欄位值 */ public static String formatField(String sValue, char cType) { String sDefault; switch (cType) { case 'N': sDefault = "0"; break; case 'P': sDefault = "0.00"; break; default: sDefault = ""; } if (sValue == null || "".equalsIgnoreCase(sValue) || "null".equalsIgnoreCase(sValue)) { sValue = sDefault; } else { sDefault = sValue; switch (cType) { case 'D': sValue = convertDate(sDefault); break; case 'N': sValue = (new DecimalFormat("#,##0")).format(Double.parseDouble(sDefault)); break; case 'P': sValue = (new DecimalFormat("#,##0.00")).format(Double.parseDouble(sDefault)); break; } } return sValue; } aptana除了IE,怎么增加别的浏览器 js如何实现点击链接后将文字显示在文本框(本身文本框是隐藏的) web的文件夹访问问题。 请教:使用JSP+Tomcat如何连接Oracle数据库? javasript validation framework 运行时错误:配置文件读取错误,请检查。 javabean配置问题????????????????? 请教自动生成报表一问 吐血三升紧急求救,高手请入 JSP和HTML 我的websphere为何无法执行html文件中的jsp代码,而jsp文件却可以正常运行! 问个JSP连接池的问题 如何在循环中写连动
df.format(v1);
such as;
System.out.println(String.format("%1f",b));
* 格式化欄位值
* @param sValue 原欄位值
* @param cType 欄位數據類型
* @return 整理後的欄位值
*/
public static String formatField(String sValue, char cType) {
String sDefault;
switch (cType) {
case 'N': sDefault = "0"; break;
case 'P': sDefault = "0.00"; break;
default: sDefault = "";
}
if (sValue == null || "".equalsIgnoreCase(sValue) || "null".equalsIgnoreCase(sValue)) {
sValue = sDefault;
} else {
sDefault = sValue;
switch (cType) {
case 'D':
sValue = convertDate(sDefault);
break;
case 'N':
sValue = (new DecimalFormat("#,##0")).format(Double.parseDouble(sDefault));
break;
case 'P':
sValue = (new DecimalFormat("#,##0.00")).format(Double.parseDouble(sDefault));
break;
}
}
return sValue;
}