久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Mac OS X 中的哪些設置會影響 Java 中的“Locale&quo

What settings in Mac OS X affect the `Locale` and `Calendar` inside Java?(Mac OS X 中的哪些設置會影響 Java 中的“Locale和“Calendar?)
本文介紹了Mac OS X 中的哪些設置會影響 Java 中的“Locale"和“Calendar"?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

這兩個問題讓我想知道 Mac OS X 中的哪些設置會影響 區(qū)域設置 和 日歷 Java 中的默認值和行為:

These two questions prompted me to wonder what settings in Mac OS X affect the Locale and Calendar defaults and behavior in Java:

  • WEEK_OF_YEAR 在不同機器上不一致
  • 為什么 Calendar.getInstance() 無法使用默認語言環(huán)境?

這些討論的關鍵是日歷中的這兩個屬性:

Key in those discussions are these two properties in Calendar:

  • firstDayOfWeek
  • minimalDaysInFirstWeek

這兩個值的默認值是 Java 7 中的 1 &8 在默認美國上運行時.什么會導致報告其他值?

The default for both those values is 1 in Java 7 & 8 when run on a default United States. What can cause other values to be reported?

推薦答案

我看到了一些奇怪的行為,這些行為會影響 java.util.Calendar 的這些屬性.

I've seen some peculiar behavior as to what affects these properties of java.util.Calendar.

確定的事實:

  • Java Locale 由 System Preferences 中的 Language 確定.
  • Calendar 的兩個屬性不受通過 Mac 的 Language 更改的 Java Locale 的影響.相反,它們是通過在系統(tǒng)偏好設置中選擇一個區(qū)域來確定的.
  • 奇怪的是,可能是一個錯誤,在系統(tǒng)偏好設置中手動選擇一周的第一天彈出菜單無法影響 Java 中的等效屬性.在選擇 Region 時影響 Mac 設置會影響 Java,但手動選擇彈出菜單不會.
  • 通過 Mac Language 設置設置 Java 區(qū)域設置不會影響日歷的屬性,但將區(qū)域設置傳遞給日歷的構造函數(shù)影響其屬性(明顯矛盾).
  • The Java Locale is determined by Language in System Preferences.
  • The two properties of Calendar are not affected by the Java Locale changed via the Mac’s Language. Instead they are determined by choosing a Region in System Preferences.
  • Oddly enough, and possibly a bug, manually choosing First day of week popup menu in System Preferences fails to affect the equivalent property in Java. Affecting that Mac setting as part of choosing Region affects Java, yet manually choosing the popup menu does not.
  • Setting the Java Locale via the Mac Language setting does not affect the Calendar's properties, yet passing a Locale to the Calendar's constructor does affect its properties (an apparent contradiction).

將此代碼作為測試運行.

Running this code as a test.

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class TestCalendar
{

    public static void main( String[] args )
    {
        Locale locale = Locale.getDefault();
        Calendar c = Calendar.getInstance();
        c.setTime( new Date( new Long( 1293840000000l ) ) );  // First moment of the year 2011 in UTC.
        System.out.println( "Locale: " + locale + " | FirstDayOfWeek: " + c.getFirstDayOfWeek() + " | MinimialDaysInFirstWeek: " + c.getMinimalDaysInFirstWeek() );
    }
}

在 Mac OS X (Mavericks) 上托管的 Parallels 9 虛擬機中使用 Mac OS X 10.8.5 (Mountain Lion),帶有 Java 8 Update 11,在安裝操作系統(tǒng),我玩弄 System Preferences > Language &文本.

Using Mac OS X 10.8.5 (Mountain Lion) in a Parallels 9 virtual machine hosted on Mac OS X (Mavericks) with Java 8 Update 11 with a United States locale chosen during installation of the OS, I played around with System Preferences > Language & Text.

奇怪的是,在 Region 選項卡上更改 First day of week 沒有任何效果.Java 報告 FirstDayOfWeek: 1 我是否將該彈出菜單設置為星期日"或星期一".

Strangely, changing First day of week on the Region tab has no effect. Java reports FirstDayOfWeek: 1 whether I set that popup menu to "Sunday" or "Monday".

Locale: en_US | FirstDayOfWeek: 1 | MinimialDaysInFirstWeek: 1

重新啟動 NetBeans IDE 沒有幫助.重新啟動 Mac(虛擬機)沒有幫助.

Restarting the NetBeans IDE does not help. Restarting the Mac (virtual machine) does not help.

區(qū)域 選項卡上,選中 顯示所有區(qū)域 復選框以查看更多區(qū)域.選擇 法語 > France.立即運行 IDE.不需要重新啟動 IDE 或操作系統(tǒng),甚至不需要關閉 System Preferences 窗口.

On the Region tab, check the Show all regions checkbox to see many more regions. Choose French > France. Run the IDE immediately. No need no restart the IDE or the OS, nor even to close the System Preferences window.

Locale: en_US | FirstDayOfWeek: 2 | MinimialDaysInFirstWeek: 4

對兩個帳戶很感興趣.

  • 現(xiàn)在我們知道 Region 設置會影響這兩個關鍵日歷設置,但 Locale 并沒有改變.作為 FirstDayOfWeek 的值 2 表示 Monday,這對于法國(以及世界大部分地區(qū))是正確的.
  • 另一個問題很奇怪,可能是一個錯誤:當設置為較大區(qū)域更改的一部分時,一周的第一天彈出窗口似乎會影響 Java,但手動選擇該彈出窗口不會影響 Java 屬性有問題.
  • Now we know the Region setting affects both of these key Calendar settings, yet the Locale has not changed. The value 2 as FirstDayOfWeek means Monday, as is correct for France (and much of the world).
  • The other issue is bizarre, perhaps a bug: The First day of week popup seems to affect Java when set as part of a larger Region change but manually selecting that popup does not affect the Java properties in question.

Region 彈出窗口重置回 United States 會恢復 Java 屬性,這是一致且符合預期的:

Resetting the Region popup back to United States restores the Java properties, which is consistent and expected:

Locale: en_US | FirstDayOfWeek: 1 | MinimialDaysInFirstWeek: 1

系統(tǒng)偏好設置 > 語言 &文字 > 語言

語言選項卡上,將Fran?ais(法語)拖到列表頂部,使其出現(xiàn)在英語之前.

System Preferences > Language & Text > Language

On the Language tab, drag Fran?ais (French) to the top of the list, so it appears before English.

立即運行 IDE.

Locale: fr_FR | FirstDayOfWeek: 1 | MinimialDaysInFirstWeek: 1

再次,有趣.現(xiàn)在我們知道 Java Locale 是由 Mac Language 設置決定的.我們知道這對相關日歷屬性沒有影響.

Again, interesting. Now we know the Java Locale is determined by the Mac Language setting. And we know that has no effect on the Calendar properties in question.

所以您認為 Mac 語言 決定了 Java 語言環(huán)境,而 Java 語言環(huán)境 影響日歷屬性?正確,當閱讀上面的內容時,但在閱讀下一節(jié)時錯誤,我們看到 Java 語言環(huán)境設置了另一種方式可以影響日歷屬性.非常混亂.

So you think Mac Language determines Java Locale, and Java Locale does not affect the Calendar properties? Right, when reading above, but Wrong when reading on to next section where we see that Java Locale set another way can affect the Calendar properties. Very confusing.

發(fā)現(xiàn)另一個矛盾.讓我們將 Mac 恢復為美國默認設置:(1) Language 列表頂部的英語,(2) 區(qū)域設置為 United States.

Another contradiction found. Let's restore the Mac back to US defaults: (1) English at top of Language list, (2) Region set to United States.

更改我們的代碼以將區(qū)域設置傳遞給日歷的構造函數(shù).

Change our code to pass a Locale to the Calendar's constructor.

Calendar c = Calendar.getInstance( Locale.FRANCE );

這會影響日歷屬性:

FirstDayOfWeek: 2 | MinimialDaysInFirstWeek: 4

所以,令人困惑的矛盾是:

So, the confusing contradiction is:

  • 通過 Mac 的語言設置 Java 區(qū)域設置不會影響日歷的屬性.
  • 將 Locale 顯式傳遞給 Calendar 構造函數(shù)影響其屬性.
  • Setting the Java Locale via the Mac's Language does not affect the Calendar's properties.
  • Explicitly passing the Locale to the Calendar constructor does affect its properties.

這篇關于Mac OS X 中的哪些設置會影響 Java 中的“Locale"和“Calendar"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 熟女毛片 | 成人精品国产 | 欧美一区二区在线观看 | 中文字幕在线免费观看 | 国产第一页在线播放 | tube国产 | 黄色小视频大全 | 狠狠操狠狠干 | 久久午夜精品 | 在线观看中文字幕 | 久久精品国产免费高清 | 91在线一区二区三区 | 国产一区二区在线播放 | 日韩男人天堂 | 一二三四在线视频观看社区 | 伊人影院在线观看 | 午夜影院 | 午夜精品福利视频 | 久久久久9999| 成人免费在线网 | 成人高潮片免费视频欧美 | 日韩午夜| 国产亚洲欧美另类一区二区三区 | www.色婷婷| 亚洲欧美在线观看 | www.国产精 | 一区二区小视频 | 在线免费国产视频 | 国产成人免费视频网站高清观看视频 | 欧美在线视频观看 | 亚洲天堂网站 | 久久大陆 | 99re国产精品 | 亚洲高清在线 | 国产精品一区二区久久精品爱微奶 | 国产乱码久久久久久 | 国产高清视频在线观看 | 国产一卡二卡三卡 | 中文字幕人成人 | 精品久久久久国产 | 午夜影视 |