Java Double to String conversion without formatting(Java Double 到 String 的转换,无需格式化)
问题描述
我的号码是 654987.它是数据库中的一个 ID.我想将其转换为字符串.常规的 Double.ToString(value) 使其成为科学形式,6.54987E5.我不想要的东西.
I have the number 654987. Its an ID in a database. I want to convert it to a string. The regular Double.ToString(value) makes it into scientific form, 6.54987E5. Something I dont want.
我发现的其他格式化函数检查当前语言环境并添加适当的千位分隔符等.由于它是一个 ID,我根本无法接受任何格式.
Other formatting functions Ive found checks the current locale and adds appropriate thousand separators and such. Since its an ID, I cant accept any formatting at all.
怎么做?
澄清:我正在研究一个将所有数字列视为双精度的特殊数据库.Double 是我可以从数据库中检索的唯一(数字)类型.
To clarify: Im working on a special database that treats all numeric columns as doubles. Double is the only (numeric) type I can retrieve from the database.
推荐答案
Use Long:
long id = 654987;
String str = Long.toString(id);
这篇关于Java Double 到 String 的转换,无需格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java Double 到 String 的转换,无需格式化
基础教程推荐
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 存储 20 位数字的数据类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
