<HTML>
<HEAD> </HEAD>

<BODY BGCOLOR=#FFFFFF>
<H2 ALIGN=center><I>Date and Time Formatting Demo Guide</I></H2>

<TABLE ALIGN=center WIDTH=100% CELLPADDING=10>
<TR>
<TD WIDTH=50% ALIGN=center> <APPLET codebase="../code" CODE="DateTimeDemo.class" WIDTH=55 HEIGHT=30 align=middle>(Java not enabled in this browser)</APPLET>
</TD>
</TR>
</TABLE>

<P>Date and time formatters convert internal time data into text strings for meaningful display.  The date and time formatters:
<UL>
	<LI> Handle timezones and daylight savings adjustments </LI>
	<LI> Support multiple calendars </LI>
	<LI> Support European date fields such as the number of the week in the year </LI>
	<LI> Like the number formatters:
		<UL>
 			<LI> Support definition of formats with string patterns and can retrieve the normalized pattern
			<LI> Can parse anything they can format </LI>
		</UL>
</UL></P>

<P><CENTER>
 <A HREF="#localized"> Localized Formatting and Parsing</A>&nbsp;
 <A HREF="#patterns"> Editing Format Patterns</A><BR>
 <A HREF="#utilities"> Date Formatting Utilities</A>
</CENTER></P>

<HR>
<H3> <A NAME="localized">Localized Formatting and Parsing </A></H3>
<P> The date and time formatters let you format the time according to the language, format, and time zone for a given country.   The formatters also provide language-specific parsing.  
</P>
<P> The applet displays the date in two formats&#151;the Java 1.0 representation (&quot;1.0 Date&quot;) and the localized format generated by the date and time formatters (&quot;New Date&quot;).
</P>

<TABLE WIDTH=100% CELLPADDING=5>
<TR>
<TH ALIGN=left VALIGN=bottom>To See This...</TH>
<TH ALIGN=left VALIGN=bottom>Do This...</TH>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> Dates localized for the language and time zones of the selected locale. (<STRONG><I>Note:</I></STRONG> Japanese is not yet displayable.)
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Pull down the Locale menu
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Try several different locales with the up and down arrow keys (on Windows) or the mouse button (on Macintosh) 
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> The formatter can parse changes to the formatted date and reflect it in the Java date and the value in milliseconds.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select an English locale
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Replace the month name in the formatted date with &quot;June&quot;
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> The formatter formats correctly for different time zones within a country, for example, Pacific or Eastern time.  It also switches automatically between standard time or daylight savings time based on the current date within the year.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select the U.S. locale
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Select the <I>Time Format</I>.  (the formatted date will indicate Pacific Daylight time)
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 3.
</TD>
<TD> Pull down the <I>City </I> menu and select different cities to see the time in different U.S. time zones
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>

<P> <STRONG><I>Note:</I></STRONG> The dates shown here are all based on the Gregorian calendar.  The time formatting classes define an abstract calendar class that can be extended to support non-Gregorian calendars.  This can be used by programmers that have no special knowledge of calendaring systems.
</P>

<HR WIDTH=50% ALIGN=left>
<H3> <A NAME="patterns"> Editing Format Patterns </A></H3>
<P> As with the number formatters, you can easily create and modify date and time formats by specifying string patterns.  You can also add new fields to the format, and create formats used for business purposes in some countries.  
</P>

<TABLE WIDTH=100% CELLPADDING=5>
<TR>
<TH ALIGN=left VALIGN=bottom>To See This...</TH>
<TH ALIGN=left VALIGN=bottom>Do This...</TH>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> The format pattern supports a variety of fields, and supports both full and abbreviated formats for some fields.  The month, for example, can be numeric, abbreviated, or full.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select the <I>Date Format </I> and the <I>English (U.S.)</I> locale
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> In the <I> Pattern </I> field, delete an &quot;M&quot;&#151;the month changes to the abbreviated format
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 3.
</TD>
<TD> Delete another &quot;M&quot;&#151;the month changes to the numeric format
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> You can specify formats used in business documents, such as day of the year.  You can also add unformatted strings to the pattern by enclosing them in single quotes.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select the month and day fields in the pattern (&quot;MM dd&quot;)
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Replace it with the string (including the single quotes) &quot;'day' D&quot;
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>

<HR WIDTH=50% ALIGN=left>
<H3> <A NAME="utilities"> Date Formatting Utilities </A></H3>
<P> The formatters also provide a number of utilities that you can use to build date and time widgets, including adding to or rolling fields.  
</P>

<TABLE WIDTH=100% CELLPADDING=5>
<TR>
<TH ALIGN=left VALIGN=bottom>To See This...</TH>
<TH ALIGN=left VALIGN=bottom>Do This...</TH>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> &quot;Rolling&quot; a field prevents other fields from being  affected by the change.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select the <I>Date Format </I> and the <I>English (U.S.)</I> locale
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Select <I>Month </I> in the Date Fields menu
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 3.
</TD>
<TD> Click on the <I> Roll </I> button and click the up-arrow button until the formatted date reaches December
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 4.
</TD>
<TD> Click again&#151;the month rolls to January but the year does not increment
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> &quot;Adding&quot; to a field causes other fields to be affected by the change as appropriate.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Click on the <I>Add </I> button
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Click on the up- or down-arrow button until the formatted date reaches January
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 3.
</TD>
<TD> Click on the down-arrow button&#151;the month changes to December, and the year decrements by one
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>

<P> Note that the formatter can handle a wide range of dates.  (<STRONG><I>Note:</I></STRONG> Currently there is a bug that causes problems with dates before 1200 BC and after 5000 AD).
</P>

<TABLE WIDTH=100% CELLPADDING=5>
<TR>
<TH ALIGN=left VALIGN=bottom>To See This...</TH>
<TH ALIGN=left VALIGN=bottom>Do This...</TH>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> The formatted date changes to reflect changes in the millisecond value of the date.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select the <I>Date Format </I> and the <I>English (U.S.)</I> locale
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Type a &quot;G&quot; at the end of the pattern string to display the era
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 3.
</TD>
<TD> Select the milliseconds field and replace it with a &quot;1&quot;
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 3.
</TD>
<TD> Add zeroes until you reach the year 5000 AD (you could also start at &quot;-1&quot; and add zeroes to go backwards in time)
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>

<P>  You can type in other dates in either date field or enter a completely new pattern to  see different formatting behaviors.  Try it out!  The formatter supports many different fields you can use to create patterns.   ASCII letters are reserved as pattern letters (unless enclosed in quotes), defined as the following:
<PRE>
    Symbol   Meaning                 Presentation        Example
    ------   -------                 ------------        -------
    G        era designator          (Text)              AD
    y        year                    (Number)            1996
    M        month in year           (Text & Number)     July & 07
    d        day in month            (Number)            10
    k        hour in day             (Number)            24
    H        hour in day, 0-based    (Number)            0
    m        minute in hour          (Number)            30
    s        second in minute        (Number)            55
    S        millisecond             (Number)            978
    E        day in week             (Text)              Tuesday
    D        day in year             (Number)            189
    F        day of week in month    (Number)            2 (2nd Wed in July)
    w        week in year            (Number)            27
    W        week in month           (Number)            2
    a        am/pm marker            (Text)              PM
    h        hour in am/pm           (Number)            12
    K        hour in am/pm, 0-based  (Number)            0
    z        time zone               (Text)              Pacific Standard Time
    '        escape for text
    ''       single quote                                '
</PRE>
</P>


<HR>
<BR>
<a href="../code/DateTimeDemo.java">The source.</a>
<p>

<HR>
<BR><a href="http://www.taligent.com/Copyright.html">&copy; Copyright 
1997</a>. All rights reserved. Taligent, Inc., IBM Corp.
</BODY>
</HTML>
