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 的转换,无需格式化


- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01