<HTML>
<HEAD>
   <TITLE></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">

<H2 ALIGN=CENTER><I>Number Formatting Demo Guide</I></H2>

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

<P>Number formatters convert binary numbers (integer or float data types)
into text strings for meaningful display. The number formatters: </P>

<UL>
<LI>Provide control over every aspect of the display, including separator
characters, optional digits, maximum and minimum decimal and integer places,
and optional prefixes and suffixes </LI>

<LI>Can produce currency and percentage formats and can be extended to
produce other formats </LI>

<LI>Allow you to specify new formats with string patterns and can retrieve
the normalized pattern </LI>

<LI>Can parse anything they can format, for use when converting text input
into binary data </LI>
</UL>

<P><CENTER>
<A HREF="#localized">Localized Formats</A> &nbsp;
<A HREF="#patterns">Creating Formats with Patterns </A> &nbsp;
<A HREF="#parsing">Parsing Text </A>
</CENTER></P>

<HR>
<H3><A NAME="localized">Localized Formats </A></H3>

<P>The number formatters let you format numbers in the ways that are appropriate
for any user's conventions, including country-specific formats such as currencies.  You can also specify other formatting options such as minimum and maximum number of digits displayed.
</P>
<P> The applet displays the number in two formats&#151;the Java 1.0 representation (&quot;Java 1.0 Number&quot;), and the localized format generated by the number formatters (&quot;New Number&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> Localized number formats.  In the international string, the separator characters change to reflect the conventions used by different countries. 
</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> Localized currency formats.  The formatter adds a prefix or suffix to indicate the currency unit.  It also uses a minus sign or parentheses to indicate negative numbers, as appropriate.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Click on the <I> Currency </I> button
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Pull down the Locale menu and try several different locales
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> Setting formatting options, for example, specifying a precise  number of decimal places. 
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Type &quot;3&quot; in the <I>Min </I> field for <I> Decimal Count </I>&#151;the formatter appends zeroes to display the specified number of decimal places
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>

<HR WIDTH=50% ALIGN=left>
<H3><A NAME="patterns">Creating Formats with Patterns </A></H3>

<P> A string pattern can control the output format for a number formatter, making it easy for you to edit a format or provide an editing mechanism for end users.  The pattern also changes to reflect any changes you make programmatically.
</P>
<P> Patterns can either be invariant (for use only by programmers) or localized (for use by end users).  Click on the <I> Localized Pattern </I> box to change the state.

<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> You can edit the pattern to create a new format.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select the <I> Default Format </I> button and the <I>English (United States) </I> locale
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Increase the maximum number for <I>Decimal Count</I>
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 3.
</TD>
<TD> Delete the &quot;&#35;&quot; characters at the end of the <I>Pattern</I> field and type in zeroes&#151;the decimal places in the <I>New Number </I> field change to zeroes
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH=50% VALIGN=top> You can edit the prefix and suffix strings, and create different patterns for positive and negative numbers.
</TD>
<TD VALIGN=top> 
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Type a plus sign (&quot;+&quot;) in the <I> Prefix </I> field for positive numbers to modify the positive number pattern
</TD>
</TR>
<TR>
<TD WIDTH=10 VALIGN=top> 2.
</TD>
<TD> Delete the minus sign from the Java 1.0 number
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>

<HR WIDTH=50% ALIGN=left>
<H3><A NAME="parsing">Parsing Text </A></H3>

<P>The number formatters not only format for any language, but can parse
numbers displayed in any language back into binary format. 
</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> Changes to the international number are parsed and reflected in the <I> Java 1.0 Number </I> field.
</TD>
<TD VALIGN=top>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=10 VALIGN=top> 1.
</TD>
<TD> Select the thousands separator character in the <I>New Number </I> field (the comma if you are still in the U.S. locale) and replace it with a number
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>

<P>The parsing mechanism is somewhat lenient. For example, a thousands
separator character can be misplaced and the parser still returns the
correct value. </P>
<P>Though not yet demonstrated here, the number formatters also handle
IEEE number symbols such as the infinity sign and NaN (for example, 0/0),
creating the correct results for both formatting and parsing. The formatters
also return the alignment point so you can line up the end of integer
portions correctly even without monospace fonts or with strange number
conventions. </P>
<P>You can type in other numbers in either number field or enter a completely new pattern to  see different formatting behaviors.  Try it out!
</P>

<HR><BR>

<a href="../code/NumberFormatDemo.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>
