Java Double到String转换而不进行格式化 [英] Java Double to String conversion without formatting

查看:119
本文介绍了Java Double到String转换而不进行格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的号码是654987.它是一个数据库中的一个ID。我想把它转换成一个字符串。
常规的Double.ToString(值)使其成为科学的形式,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.

其他格式化功能Ive发现检查当前区域设置,并添加适当的千个分隔符等。自从它的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.

推荐答案

long id = 654987;
String str = Long.toString(id);

这篇关于Java Double到String转换而不进行格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆