SCJP題庫第164題

Given:
1. d is a valid, non-null Date object
2. df is a valid, non-null DateFormat object set to the current locale
What outputs the current locale's country name and the appropriate version of d's date?


A. Locale loc = Locale.getLocale();
    System.out.println(loc.getDisplayCountry()
    + " " + df.format(d));
B. Locale loc = Locale.getDefault();
    System.out.println(loc.getDisplayCountry()
    + " " + df.format(d));
C. Locale loc = Locale.getLocale();
    System.out.println(loc.getDisplayCountry()
    + " " + df.setDateFormat(d));
D. Locale loc = Locale.getDefault();
    System.out.println(loc.getDisplayCountry()
    + " " + df.setDateFormat(d));
 
Ans: B
 
解說:
Locale是本地化(/國際化)程式撰寫工具方法,locale 是指一個有共同語言和習慣的地理或政治區域。在 Java 編程語言中,locale Locale 對像來代表。對 locale 敏感的操作(例如排序原則和日期格式化)將根據 Locale 而變化。
請參考:
http://my.freebsd.org.hk/html/jdk1.2/guide/internat/intl.doc.html
http://my.freebsd.org.hk/html/jdk1.2/guide/internat/index.html

Comments

Popular posts from this blog

Android-使用webview在V3版的Google地圖GPS定位