社区
Java SE
帖子详情
如何将DecimalFormat的字符串返还转换为数字?
showboat
2008-03-07 04:10:17
DecimalFormat nf = new DecimalFormat ("###,###,###,###,##0.00") ;
现在要将53,135.98转换为53135.98?
...全文
324
3
打赏
收藏
如何将DecimalFormat的字符串返还转换为数字?
DecimalFormat nf = new DecimalFormat ("###,###,###,###,##0.00") ; 现在要将53,135.98转换为53135.98?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
tt2451
2008-03-07
打赏
举报
回复
DecimalFormat nf = new DecimalFormat ("###,###,###,###,##0.00") ;
Number a = null;
try
{
a = nf.parse("53,135.98");
}
catch (ParseException e)
{
e.printStackTrace();
}
double b=a.doubleValue();
nihuajie05
2008-03-07
打赏
举报
回复
我查不到....
只好用StringTokenizer了...
nihuajie05
2008-03-07
打赏
举报
回复
public static void main(String[] agrs)
{
DecimalFormat nf = new DecimalFormat ("###,###,###,###,##0.00") ;
System.out.println(nf.format(123456.123));
double d = 0;
try{
String str=nf.format(123456.123);
String newstr="";
StringTokenizer st=new StringTokenizer (str,",");
while(st.hasMoreElements())
{
newstr=newstr+st.nextToken();
}
d=Double.parseDouble(newstr);
}catch(NumberFormatException e){System.out.println("nihuajie");}
System.out.println(d);
}
如何把字符
转换
成
数字
java_【转】Java:
数字
与
字符串
,相互
转换
的方法
**一、
数字
与
字符串
,相互
转换
的方法有如下这些,特别注意的是,不管使用哪种方法,
字符串
为空或者
数字
未初始化都是不允许的,编译或运行中会报错二、自己实例中,值得学习第5小段代码**1如何将字串 String
转换
成整数 ...
Java将双精度
转换
为
字符串
Today we will see different ways to convert double to string in java. Java double to string conversion can be done in many ways, we will go through them one by one with example ... 今天,我们将看到...
Android开发:
数字
转换
工具封装,包含
字符串
是否可以
转换
成
数字
该工具封装了
字符串
转int、double等方法,以及判断
字符串
是否可以
转换
成
数字
/** *
数字
转换
算法工具 */ public class DecimalUtil { private static Pattern pattern = Pattern.compile("^[-\\+]?[.\\d]*$"); ...
java
字符串
转
数字
(java
字符串
转
数字
异常)
Java
字符串
日期
数字
格式化输出情况是什么? 88)); 定制格式化
数字
可是对于稍微复杂一点的需求,NumberFormat就满足不了了,幸好java还提供了
DecimalFormat
实现定制的格式化。要使用
DecimalFormat
对象,必须提供给...
Java如何将
字符串
转换
为小数_在Java中将
字符串
转换
为带有2个小数位的十进制数...
在那里你根据需要将你的浮动格式化为
字符串
,但是然后该
字符串
再次
转换
为浮点数,然后你在stdout中打印的是你的浮点数得到了标准格式.看看这段代码import java.text.
DecimalFormat
;String stringLitersOfPetrol ...
Java SE
62,623
社区成员
307,257
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章