timezone.html

来自「j2se5-api-zh,java文档的中文版本」· HTML 代码 · 共 909 行 · 第 1/3 页

HTML
909
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_03) on Wed Nov 02 09:51:21 CST 2005 --><META http-equiv="Content-Type" content="text/html; charset=gb2312"><TITLE>TimeZone (Java 2 Platform SE 5.0)</TITLE><META NAME="keywords" CONTENT="java.util.TimeZone class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="TimeZone (Java 2 Platform SE 5.0)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="跳过导航链接"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>概述</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>软件包</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>类</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/TimeZone.html"><FONT CLASS="NavBarFont1"><B>使用</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>树</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>已过时</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>索引</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>帮助</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Standard&nbsp;Ed. 5.0</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="TimerTask.html" title="java.util 中的类"><B>上一个类</B></A>&nbsp;&nbsp;<A HREF="TooManyListenersException.html" title="java.util 中的类"><B>下一个类</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html@java_2Futil_2FTimeZone.html" target="_top"><B>框架</B></A>  &nbsp;&nbsp;<A HREF="TimeZone.html" target="_top"><B>无框架</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../allclasses-noframe.html"><B>所有类</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../allclasses-noframe.html"><B>所有类</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  摘要:&nbsp;嵌套&nbsp;|&nbsp;<A HREF="#field_summary">字段</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">构造方法</A>&nbsp;|&nbsp;<A HREF="#method_summary">方法</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">详细信息:&nbsp;<A HREF="#field_detail">字段</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">构造方法</A>&nbsp;|&nbsp;<A HREF="#method_detail">方法</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.util</FONT><BR>类 TimeZone</H2><PRE><A HREF="../lang/Object.html" title="java.lang 中的类">java.lang.Object</A>  <IMG SRC="../../resources/inherit.gif" ALT="继承者 "><B>java.util.TimeZone</B></PRE><DL><DT><B>所有已实现的接口:</B> <DD>java.io.Serializable, <A HREF="../lang/Cloneable.html" title="java.lang 中的接口">Cloneable</A></DD></DL><DL><DT><B>直接已知子类:</B> <DD><A HREF="SimpleTimeZone.html" title="java.util 中的类">SimpleTimeZone</A></DD></DL><HR><DL><DT><PRE>public abstract class <B>TimeZone</B><DT>extends <A HREF="../lang/Object.html" title="java.lang 中的类">Object</A><DT>implements java.io.Serializable, <A HREF="../lang/Cloneable.html" title="java.lang 中的接口">Cloneable</A></DL></PRE><P><code>TimeZone</code> 表示时区偏移量,也可以计算夏令时。 <p>通常,使用 <code>getDefault</code> 获得 <code>TimeZone</code>,<code>getDefault</code> 基于程序运行所在的时区创建 <code>TimeZone</code>。例如,对于在日本运行的程序,<code>getDefault</code> 基于日本标准时间创建 <code>TimeZone</code> 对象。 <p>也可以用 <code>getTimeZone</code> 及时区 ID 获取 <code>TimeZone</code> 。例如美国太平洋时区的时区 ID 是 &quot;America/Los_Angeles&quot;。因此,可以使用下面语句获得美国太平洋时间 <code>TimeZone</code> 对象: <blockquote><pre> TimeZone tz = TimeZone.getTimeZone(&quot;America/Los_Angeles&quot;); </pre></blockquote>可以使用 <code>getAvailableIDs</code> 方法来对所有受支持的时区 ID 进行迭代。可以选择受支持的 ID 来获得 <code>TimeZone</code>。如果想要的时区无法用受支持的 ID 之一表示,那么可以指定自定义时区 ID 来生成 TimeZone。自定义时区 ID 的语法是: <blockquote><pre> <a name="CustomID"><i>CustomID:</i></a>         <code>GMT</code> <i>Sign</i> <i>Hours</i> <code>:</code> <i>Minutes</i>         <code>GMT</code> <i>Sign</i> <i>Hours</i> <i>Minutes</i>         <code>GMT</code> <i>Sign</i> <i>Hours</i><i>Sign:</i> 下面之一         <code>+ -</code> <i>Hours:</i>         <i>Digit</i>         <i>Digit</i> <i>Digit</i> <i>Minutes:</i>         <i>Digit</i> <i>Digit</i> <i>Digit:</i> 下面之一         <code>0 1 2 3 4 5 6 7 8 9</code> </pre></blockquote><i>Hours</i> 必须在 0 至 23 之间,<i>Minutes</i> 必须在 00 至 59 之间。例如,&quot;GMT+10&quot; 和 &quot;GMT+0010&quot; 分别意味着比 GMT 提前 10 小时和 10 分钟。 <p>格式是与区域无关的,并且数字必须取自 Unicode 标准的 Basic Latin 块。没有夏令时转换安排可以用自定义时区 ID 指定。如果指定的字符串与语法不匹配,就使用 <code>&quot;GMT&quot;</code>。 <p>当创建一个 <code>TimeZone</code> 时,指定的自定义时区 ID 采用下面的语法进行标准化: <blockquote><pre> <a name="NormalizedCustomID"><i>NormalizedCustomID:</i></a>         <code>GMT</code> <i>Sign</i> <i>TwoDigitHours</i> <code>:</code> <i>Minutes</i><i>Sign:</i> 下面之一         <code>+ -</code> <i>TwoDigitHours:</i>         <i>Digit</i> <i>Digit</i> <i>Minutes:</i>         <i>Digit</i> <i>Digit</i> <i>Digit:</i> 下面之一         <code>0 1 2 3 4 5 6 7 8 9</code> </pre></blockquote>例如,TimeZone.getTimeZone(&quot;GMT-8&quot;).getID() 返回 &quot;GMT-08:00&quot;。<h4>三字母时区 ID</h4> 为了与 JDK 1.1.x 兼容,一些三字母时区 ID(比如 &quot;PST&quot;、&quot;CTT&quot;、&quot;AST&quot;)也受支持。但是,<strong>它们的使用被废弃</strong>,这是因为相同的缩写经常用于多个时区(例如,&quot;CST&quot; 可以是美国的 &quot;Central Standard Time&quot; 和 &quot;China Standard Time&quot;),但是 Java 平台只可以识别其中一种。<P><P><DL><DT><B>从以下版本开始:</B></DT>  <DD>JDK1.1</DD><DT><B>另请参见:</B><DD><A HREF="Calendar.html" title="java.util 中的类"><CODE>Calendar</CODE></A>, <A HREF="GregorianCalendar.html" title="java.util 中的类"><CODE>GregorianCalendar</CODE></A>, <A HREF="SimpleTimeZone.html" title="java.util 中的类"><CODE>SimpleTimeZone</CODE></A>, <A HREF="../../serialized-form.html#java.util.TimeZone">序列化表格</A></DL><HR><P><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>字段摘要</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#LONG">LONG</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;指出长名称的 <code>getDisplayName()</code> 的风格说明符。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#SHORT">SHORT</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;指出短名称(比如 &quot;PST&quot;)的 <code>getDisplayName()</code> 的风格说明符。</TD></TR></TABLE>&nbsp;<!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>构造方法摘要</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="TimeZone.html#TimeZone()">TimeZone</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;单独的构造方法。</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>方法摘要</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../lang/Object.html" title="java.lang 中的类">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#clone()">clone</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;创建此 <code>TimeZone</code> 的一个副本。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../lang/String.html" title="java.lang 中的类">String</A>[]</CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getAvailableIDs()">getAvailableIDs</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;获取受支持的所有可用 ID。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="../lang/String.html" title="java.lang 中的类">String</A>[]</CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getAvailableIDs(int)">getAvailableIDs</A></B>(int&nbsp;rawOffset)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;根据给定的时区偏移量获取可用的 ID。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="TimeZone.html" title="java.util 中的类">TimeZone</A></CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getDefault()">getDefault</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;获取此主机的默认 <code>TimeZone</code>。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../lang/String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getDisplayName()">getDisplayName</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回适合于展示给默认区域的用户的时区名称。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../lang/String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getDisplayName(boolean, int)">getDisplayName</A></B>(boolean&nbsp;daylight,               int&nbsp;style)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回适合于展示给默认区域的用户的时区名称。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../lang/String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getDisplayName(boolean, int, java.util.Locale)">getDisplayName</A></B>(boolean&nbsp;daylight,               int&nbsp;style,               <A HREF="Locale.html" title="java.util 中的类">Locale</A>&nbsp;locale)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回适合于展示给指定区域的用户的时区名称。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../lang/String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getDisplayName(java.util.Locale)">getDisplayName</A></B>(<A HREF="Locale.html" title="java.util 中的类">Locale</A>&nbsp;locale)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回适合于展示给指定区域的用户的时区名称。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getDSTSavings()">getDSTSavings</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回要添加到本地标准时间以获取本地挂钟时间的时间量。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../lang/String.html" title="java.lang 中的类">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="TimeZone.html#getID()">getID</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;获取此时区的 ID。</TD></TR>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?