locale.html
来自「API資料大全」· HTML 代码 · 共 1,308 行 · 第 1/4 页
HTML
1,308 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:36:57 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class Locale</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Locale.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/util/ListResourceBundle.html"><B>PREV CLASS</B></A> <A HREF="../../java/util/Observable.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Locale.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.util</FONT><BR>Class Locale</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<B>java.util.Locale</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../java/lang/Cloneable.html">Cloneable</A>, <A HREF="../../java/io/Serializable.html">Serializable</A></DD></DL><HR><DL><DT>public final class <B>Locale</B><DT>extends <A HREF="../../java/lang/Object.html">Object</A><DT>implements <A HREF="../../java/lang/Cloneable.html">Cloneable</A>, <A HREF="../../java/io/Serializable.html">Serializable</A></DL><P>A <code>Locale</code> object represents a specific geographical, political, or cultural region. An operation that requires a <code>Locale</code> to perform its task is called <em>locale-sensitive</em> and uses the <code>Locale</code> to tailor information for the user. For example, displaying a number is a locale-sensitive operation--the number should be formatted according to the customs/conventions of the user's native country, region, or culture. <P> You create a <code>Locale</code> object using one of the two constructors in this class: <blockquote> <pre> Locale(String language, String country) Locale(String language, String country, String variant) </pre> </blockquote> The first argument to both constructors is a valid <STRONG>ISO Language Code.</STRONG> These codes are the lower-case two-letter codes as defined by ISO-639. You can find a full list of these codes at a number of sites, such as: <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> <code>http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</code></a> <P> The second argument to both constructors is a valid <STRONG>ISO Country Code.</STRONG> These codes are the upper-case two-letter codes as defined by ISO-3166. You can find a full list of these codes at a number of sites, such as: <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> <code>http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</code></a> <P> The second constructor requires a third argument--the <STRONG>Variant.</STRONG> The Variant codes are vendor and browser-specific. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are two variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might construct a locale with parameters for language, country and variant as: "es", "ES", "Traditional_WIN". <P> Because a <code>Locale</code> object is just an identifier for a region, no validity check is performed when you construct a <code>Locale</code>. If you want to see whether particular resources are available for the <code>Locale</code> you construct, you must query those resources. For example, ask the <code>NumberFormat</code> for the locales it supports using its <code>getAvailableLocales</code> method. <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular locale, you get back the best available match, not necessarily precisely what you asked for. For more information, look at <A HREF="../../java/util/ResourceBundle.html"><CODE>ResourceBundle</CODE></A>. <P> The <code>Locale</code> class provides a number of convenient constants that you can use to create <code>Locale</code> objects for commonly used locales. For example, the following creates a <code>Locale</code> object for the United States: <blockquote> <pre> Locale.US </pre> </blockquote> <P> Once you've created a <code>Locale</code> you can query it for information about itself. Use <code>getCountry</code> to get the ISO Country Code and <code>getLanguage</code> to get the ISO Language Code. You can use <code>getDisplayCountry</code> to get the name of the country suitable for displaying to the user. Similarly, you can use <code>getDisplayLanguage</code> to get the name of the language suitable for displaying to the user. Interestingly, the <code>getDisplayXXX</code> methods are themselves locale-sensitive and have two versions: one that uses the default locale and one that uses the locale specified as an argument. <P> The Java 2 platform provides a number of classes that perform locale-sensitive operations. For example, the <code>NumberFormat</code> class formats numbers, currency, or percentages in a locale-sensitive manner. Classes such as <code>NumberFormat</code> have a number of convenience methods for creating a default object of that type. For example, the <code>NumberFormat</code> class provides these three convenience methods for creating a default <code>NumberFormat</code> object: <blockquote> <pre> NumberFormat.getInstance() NumberFormat.getCurrencyInstance() NumberFormat.getPercentInstance() </pre> </blockquote> These methods have two variants; one with an explicit locale and one without; the latter using the default locale. <blockquote> <pre> NumberFormat.getInstance(myLocale) NumberFormat.getCurrencyInstance(myLocale) NumberFormat.getPercentInstance(myLocale) </pre> </blockquote> A <code>Locale</code> is the mechanism for identifying the kind of object (<code>NumberFormat</code>) that you would like to get. The locale is <STRONG>just</STRONG> a mechanism for identifying objects, <STRONG>not</STRONG> a container for the objects themselves. <P> Each class that performs locale-sensitive operations allows you to get all the available objects of that type. You can sift through these objects by language, country, or variant, and use the display names to present a menu to the user. For example, you can create a menu of all the collation objects suitable for a given language. Such classes must implement these three class methods: <blockquote> <pre> public static Locale[] getAvailableLocales() public static String getDisplayName(Locale objectLocale, Locale displayLocale) public static final String getDisplayName(Locale objectLocale) // getDisplayName will throw MissingResourceException if the locale // is not one of the available locales. </pre> </blockquote><P><DL><DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/util/ResourceBundle.html"><CODE>ResourceBundle</CODE></A>, <A HREF="../../java/text/Format.html"><CODE>Format</CODE></A>, <A HREF="../../java/text/NumberFormat.html"><CODE>NumberFormat</CODE></A>, <A HREF="../../java/text/Collator.html"><CODE>Collator</CODE></A>, <A HREF="../../serialized-form.html#java.util.Locale">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#CANADA">CANADA</A></B></CODE><BR> Useful constant for country.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#CANADA_FRENCH">CANADA_FRENCH</A></B></CODE><BR> Useful constant for country.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#CHINA">CHINA</A></B></CODE><BR> Useful constant for country.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#CHINESE">CHINESE</A></B></CODE><BR> Useful constant for language.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#ENGLISH">ENGLISH</A></B></CODE><BR> Useful constant for language.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#FRANCE">FRANCE</A></B></CODE><BR> Useful constant for country.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#FRENCH">FRENCH</A></B></CODE><BR> Useful constant for language.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#GERMAN">GERMAN</A></B></CODE><BR> Useful constant for language.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#GERMANY">GERMANY</A></B></CODE><BR> Useful constant for country.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#ITALIAN">ITALIAN</A></B></CODE><BR> Useful constant for language.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#ITALY">ITALY</A></B></CODE><BR> Useful constant for country.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#JAPAN">JAPAN</A></B></CODE><BR> Useful constant for country.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#JAPANESE">JAPANESE</A></B></CODE><BR> Useful constant for language.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/util/Locale.html">Locale</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/util/Locale.html#KOREA">KOREA</A></B></CODE><BR>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?