gpt4 book ai didi

C# 中 CultureInfo.InvariantCulture 属性的 Java 等价物

转载 作者:行者123 更新时间:2023-11-30 11:05:06 25 4
gpt4 key购买 nike

是的,我是 java 的新手,这个问题在 stackoverflow (Java equivalent of Invariant Culture) 的其他一些链接中被问到。但仍然没有结论表明,

  1. Java 中没有相应的工具可以做到这一点
  2. 还有一个选择

下面的语句在 java 中会做什么。

Locale invariant = new Locale("","","");

我对上面的语句很感兴趣,因为在 C# 中,下面的代码将带来不变的文化设置。

CultureInfo Invc = New CultureInfo("");

我想知道这是否可能在 Java 中具有不变的文化设置,是否有可能通过任何变通方法或如何在具有独立文化设置的 Java 中编写代码。下面的 MSDN 引用说明了独立文化设置的必要性。

Storing data in a culture-independent format guarantees a known format that does not change. When users from different cultures access the data, it can be formatted appropriately based on specific user. For example, if your application stores DateTime types in a text file, formatted for the invariant culture, the application should use the InvariantCulture property when calling ToString to store the strings and the Parse method to retrieve the strings. This technique ensures that the underlying values of the DateTime types do not change when the data is read or written by users from different cultures.

最佳答案

比较 Locale.ROOT :

The root locale is the locale whose language, country, and variant are empty ("") strings. This is regarded as the base locale of all locales, and is used as the language/country neutral locale for the locale sensitive operations.

关于C# 中 CultureInfo.InvariantCulture 属性的 Java 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29765716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com