這個問題似乎非常簡單,但我很尷尬地說我還沒有弄清楚它是如何工作的。從操作系統獲取數字格式
我希望我的Java SE應用程序能夠從操作系統中的任何配置中獲取其數字格式。就像該操作系統上的其他應用程序一樣。
我的目標主要是Windows。考慮在Windows中,這個例子:
我用這個小例子,檢查結果:
public class MyMain {
public static void main(String[] args) {
DecimalFormat decFormat = new DecimalFormat();
DecimalFormatSymbols decSymbols = decFormat.getDecimalFormatSymbols();
System.out.println("Decimal separator is : " + decSymbols.getDecimalSeparator());
System.out.println("Thousands separator is : " + decSymbols.getGroupingSeparator());
}
}
隨着截圖上面的例子我的小Java示例打印:
Decimal separator is : ,
Thousands separator is : .
我希望它能說小數點分隔符是一個點,而千位分隔符是逗號 - 因爲這是我告訴Windows的,而這正是所有其他Windows應用程序所採用的。
我的印象是,在Windows中這些設置對新進程起作用。我試過重新啓動我的IDE。沒有幫助。
我在做什麼錯?
Look [here](http://stackoverflow.com/questions/838590/how-to-read-list-separator-from-os-in-java) – Jens
看來你需要從註冊表,如果你需要它。 –
@Jarrod他們似乎沒有詢問有關'Locale'的格式。 –