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);
相关文章