format.html

来自「API資料大全」· HTML 代码 · 共 442 行 · 第 1/2 页

HTML
442
字号
<!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:39 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class  Format</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>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Format.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</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>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../java/text/FieldPosition.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../java/text/MessageFormat.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>  &nbsp;&nbsp;<A HREF="Format.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.text</FONT><BR>Class  Format</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A>  |  +--<B>java.text.Format</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><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../java/text/DateFormat.html">DateFormat</A>, <A HREF="../../java/text/MessageFormat.html">MessageFormat</A>, <A HREF="../../java/text/NumberFormat.html">NumberFormat</A></DD></DL><HR><DL><DT>public abstract class <B>Format</B><DT>extends <A HREF="../../java/lang/Object.html">Object</A><DT>implements <A HREF="../../java/io/Serializable.html">Serializable</A>, <A HREF="../../java/lang/Cloneable.html">Cloneable</A></DL><P><code>Format</code> is an abstract base class for formatting locale-sensitive information such as dates, messages, and numbers. <p> <code>Format</code> defines the programming interface for formatting locale-sensitive objects into <code>String</code>s (the <code>format</code> method) and for parsing <code>String</code>s back into objects (the <code>parseObject</code> method). Any <code>String</code> formatted by <code>format</code> is guaranteed to be parseable by <code>parseObject</code>. <p> If formatting is unsuccessful because the <code>Format</code> object cannot format the type of object specified, <code>format</code> throws an <code>IllegalArgumentException</code>. Otherwise, if there is something illformed about the object, <code>format</code> returns the Unicode replacement character <code>\\uFFFD</code>. <p> If there is no match when parsing, <code>parseObject(String)</code> throws a <code>ParseException</code>, and <code>parseObject(String, ParsePosition)</code> leaves the <code>ParsePosition</code> <code>index</code> member unchanged and returns <code>null</code>. <p> <STRONG>Subclassing:</STRONG> The Java 2 platform provides three concrete subclasses of <code>Format</code>-- <code>DateFormat</code>, <code>MessageFormat</code>, and <code>NumberFormat</code>--for formatting dates, messages, and numbers, respectively. <p> Concrete subclasses <em>must</em> implement these two methods: <ol> <li> <code>format(Object obj, StringBuffer toAppendTo, FieldPosition pos)</code> <li> <code>parseObject (String source, ParsePosition pos)</code> </ol> <p> Most subclasses will also implement the following two methods: <ol> <li> <code>getInstance</code> for getting a useful format object appropriate for the current locale <li> <code>getInstance(Locale)</code> for getting a useful format object appropriate for the specified locale </ol> In addition, some subclasses may also choose to implement other <code>getXxxxInstance</code> methods for more specialized control. For example, the <code>NumberFormat</code> class provides <code>getPercentInstance</code> and <code>getCurrencyInstance</code> methods for getting specialized number formatters. <p> Subclasses of <code>Format</code> that allow programmers to create objects for locales (with <code>getInstance(Locale)</code> for example) must also implement the following class method: <blockquote> <pre> public static Locale[] getAvailableLocales() </pre> </blockquote> <p> And finally subclasses may define a set of constants to identify the various fields in the formatted output. These constants are used to create a FieldPosition object which identifies what information is contained in the field and its position in the formatted result. These constants should be named <code><em>item</em>_FIELD</code> where <code><em>item</em></code> identifies the field. For examples of these constants, see <code>ERA_FIELD</code> and its friends in <A HREF="../../java/text/DateFormat.html"><CODE>DateFormat</CODE></A>.<P><DL><DT><B>See Also: </B><DD><A HREF="../../java/text/ParsePosition.html"><CODE>ParsePosition</CODE></A>, <A HREF="../../java/text/FieldPosition.html"><CODE>FieldPosition</CODE></A>, <A HREF="../../java/text/NumberFormat.html"><CODE>NumberFormat</CODE></A>, <A HREF="../../java/text/DateFormat.html"><CODE>DateFormat</CODE></A>, <A HREF="../../java/text/MessageFormat.html"><CODE>MessageFormat</CODE></A>, <A HREF="../../serialized-form.html#java.text.Format">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/text/Format.html#Format()">Format</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/Format.html#clone()">clone</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Overrides Cloneable</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/Format.html#format(java.lang.Object)">format</A></B>(<A HREF="../../java/lang/Object.html">Object</A>&nbsp;obj)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats an object to produce a string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>abstract &nbsp;<A HREF="../../java/lang/StringBuffer.html">StringBuffer</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/Format.html#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)">format</A></B>(<A HREF="../../java/lang/Object.html">Object</A>&nbsp;obj,       <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A>&nbsp;toAppendTo,       <A HREF="../../java/text/FieldPosition.html">FieldPosition</A>&nbsp;pos)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats an object to produce a string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/Format.html#parseObject(java.lang.String)">parseObject</A></B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;source)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parses a string to produce an object.</TD>

⌨️ 快捷键说明

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