datetimeconverter.html

来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 994 行 · 第 1/4 页

HTML
994
字号
<!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_14) on Mon Jan 28 05:46:52 PST 2008 --><TITLE>DateTimeConverter (Java EE 5)</TITLE><META NAME="keywords" CONTENT="javax.faces.convert.DateTimeConverter class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="DateTimeConverter (Java EE 5)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></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>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="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-all.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></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../javax/faces/convert/ConverterException.html" title="class in javax.faces.convert"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../../javax/faces/convert/DoubleConverter.html" title="class in javax.faces.convert"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html?javax/faces/convert/DateTimeConverter.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="DateTimeConverter.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&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;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.faces.convert</FONT><BR>Class DateTimeConverter</H2><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>  <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>javax.faces.convert.DateTimeConverter</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../javax/faces/component/StateHolder.html" title="interface in javax.faces.component">StateHolder</A>, <A HREF="../../../javax/faces/convert/Converter.html" title="interface in javax.faces.convert">Converter</A></DD></DL><HR><DL><DT><PRE>public class <B>DateTimeConverter</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A><DT>implements <A HREF="../../../javax/faces/convert/Converter.html" title="interface in javax.faces.convert">Converter</A>, <A HREF="../../../javax/faces/component/StateHolder.html" title="interface in javax.faces.component">StateHolder</A></DL></PRE><P><p><A HREF="../../../javax/faces/convert/Converter.html" title="interface in javax.faces.convert"><CODE>Converter</CODE></A> implementation for <code>java.util.Date</code> values.</p> <p>The <code>getAsObject()</code> method parses a String into a <code>java.util.Date</code>, according to the following algorithm:</p> <ul> <li>If the specified String is null, return     a <code>null</code>.  Otherwise, trim leading and trailing     whitespace before proceeding.</li> <li>If the specified String - after trimming - has a zero length,     return <code>null</code>.</li> <li>If the <code>locale</code> property is not null,     use that <code>Locale</code> for managing parsing.  Otherwise, use the     <code>Locale</code> from the <code>UIViewRoot</code>.</li> <li>If a <code>pattern</code> has been specified, its syntax must conform     the rules specified by <code>java.text.SimpleDateFormat</code>.  Such     a pattern will be used to parse, and the <code>type</code>,     <code>dateStyle</code>, and <code>timeStyle</code> properties     will be ignored.</li> <li>If a <code>pattern</code> has not been specified, parsing will be based     on the <code>type</code> property, which expects a date value, a time     value, or both.  Any date and time values included will be parsed in     accordance to the styles specified by <code>dateStyle</code> and     <code>timeStyle</code>, respectively.</li> <li>If a <code>timezone</code> has been specified, it must be passed     to the underlying <code>DateFormat</code> instance.  Otherwise     the "GMT" timezone is used.</li> <li>In all cases, parsing must be non-lenient; the given string must     strictly adhere to the parsing format.</li> </ul> <p>The <code>getAsString()</code> method expects a value of type <code>java.util.Date</code> (or a subclass), and creates a formatted String according to the following algorithm:</p> <ul> <li>If the specified value is null, return a zero-length String.</li> <li>If the specified value is a String, return it unmodified.</li> <li>If the <code>locale</code> property is not null,     use that <code>Locale</code> for managing formatting.  Otherwise, use the     <code>Locale</code> from the <code>UIViewRoot</code>.</li> <li>If a <code>timezone</code> has been specified, it must be passed     to the underlying <code>DateFormat</code> instance.  Otherwise     the "GMT" timezone is used.</li> <li>If a <code>pattern</code> has been specified, its syntax must conform     the rules specified by <code>java.text.SimpleDateFormat</code>.  Such     a pattern will be used to format, and the <code>type</code>,     <code>dateStyle</code>, and <code>timeStyle</code> properties     will be ignored.</li> <li>If a <code>pattern</code> has not been specified, formatting will be     based on the <code>type</code> property, which includes a date value,     a time value, or both into the formatted String.  Any date and time     values included will be formatted in accordance to the styles specified     by <code>dateStyle</code> and <code>timeStyle</code>, respectively.</li> </ul><P><P><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>Field Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/DateTimeConverter.html#CONVERTER_ID">CONVERTER_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The standard converter id for this converter.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/DateTimeConverter.html#DATE_ID">DATE_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if the conversion to <code>Date</code> fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/DateTimeConverter.html#DATETIME_ID">DATETIME_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if the conversion to <code>DateTime</code> fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/DateTimeConverter.html#STRING_ID">STRING_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if  the conversion of the <code>DateTime</code> value to  <code>String</code> fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/DateTimeConverter.html#TIME_ID">TIME_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if the conversion to <code>Time</code> fails.</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>Constructor Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javax/faces/convert/DateTimeConverter.html#DateTimeConverter()">DateTimeConverter</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" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Method Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/DateTimeConverter.html#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)">getAsObject</A></B>(<A HREF="../../../javax/faces/context/FacesContext.html" title="class in javax.faces.context">FacesContext</A>&nbsp;context,            <A HREF="../../../javax/faces/component/UIComponent.html" title="class in javax.faces.component">UIComponent</A>&nbsp;component,            <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;value)</CODE><BR>

⌨️ 快捷键说明

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