問題描述
我的號碼是 654987.它是數(shù)據(jù)庫中的一個 ID.我想將其轉換為字符串.常規(guī)的 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.
我發(fā)現(xiàn)的其他格式化函數(shù)檢查當前語言環(huán)境并添加適當?shù)那环指舴?由于它是一個 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.
怎么做?
澄清:我正在研究一個將所有數(shù)字列視為雙精度的特殊數(shù)據(jù)庫.Double 是我可以從數(shù)據(jù)庫中檢索的唯一(數(shù)字)類型.
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 的轉換,無需格式化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!