3377N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * An interpreter for printf-style format strings. This class provides support 0N/A * for layout justification and alignment, common formats for numeric, string, 0N/A * and date/time data, and locale-specific output. Common Java types such as 847N/A * {@code byte}, {@link java.math.BigDecimal BigDecimal}, and {@link Calendar} 0N/A * are supported. Limited formatting customization for arbitrary user types is 0N/A * provided through the {@link Formattable} interface. 0N/A * <p> Formatters are not necessarily safe for multithreaded access. Thread 0N/A * safety is optional and is the responsibility of users of methods in this 0N/A * <p> Formatted printing for the Java language is heavily inspired by C's 847N/A * {@code printf}. Although the format strings are similar to C, some 0N/A * customizations have been made to accommodate the Java language and exploit 0N/A * some of its features. Also, Java formatting is more strict than C's; for 0N/A * example, if a conversion is incompatible with a flag, an exception will be 0N/A * thrown. In C inapplicable flags are silently ignored. The format strings 0N/A * are thus intended to be recognizable to C programmers but not necessarily 0N/A * completely compatible with those in C. 0N/A * <p> Examples of expected usage: 0N/A * StringBuilder sb = new StringBuilder(); 0N/A * // Send all output to the Appendable object sb 0N/A * Formatter formatter = new Formatter(sb, Locale.US); 0N/A * // Explicit argument indices may be used to re-order output. 0N/A * formatter.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d") 0N/A * // -> " d c b a" 0N/A * // Optional locale as the first argument can be used to get 0N/A * // locale-specific formatting of numbers. The precision and width can be 0N/A * // given to round and align the value. 0N/A * formatter.format(Locale.FRANCE, "e = %+10.4f", Math.E); 0N/A * // -> "e = +2,7183" 0N/A * // The '(' numeric flag may be used to format negative numbers with 0N/A * // parentheses rather than a minus sign. Group separators are 0N/A * // automatically inserted. 0N/A * formatter.format("Amount gained or lost since last statement: $ %(,.2f", 0N/A * // -> "Amount gained or lost since last statement: $ (6,217.58)" 0N/A * </pre></blockquote> 0N/A * <p> Convenience methods for common formatting requests exist as illustrated 0N/A * by the following invocations: 0N/A * // Writes a formatted string to System.out. 0N/A * System.out.format("Local time: %tT", Calendar.getInstance()); 0N/A * // -> "Local time: 13:34:18" 0N/A * // Writes formatted output to System.err. 0N/A * System.err.printf("Unable to open file '%1$s': %2$s", 0N/A * fileName, exception.getMessage()); 0N/A * // -> "Unable to open file 'food': No such file or directory" 0N/A * </pre></blockquote> 847N/A * <p> Like C's {@code sprintf(3)}, Strings may be formatted using the static 0N/A * method {@link String#format(String,Object...) String.format}: 0N/A * // Format a string containing a date. 0N/A * import java.util.Calendar; 0N/A * import java.util.GregorianCalendar; 0N/A * import static java.util.Calendar.*; 0N/A * Calendar c = new GregorianCalendar(1995, MAY, 23); 0N/A * String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c); 0N/A * // -> s == "Duke's Birthday: May 23, 1995" 0N/A * </pre></blockquote> 0N/A * <h3><a name="org">Organization</a></h3> 0N/A * <p> This specification is divided into two sections. The first section, <a 0N/A * href="#summary">Summary</a>, covers the basic formatting concepts. This 0N/A * section is intended for users who want to get started quickly and are 0N/A * familiar with formatted printing in other programming languages. The second 0N/A * section, <a href="#detail">Details</a>, covers the specific implementation 0N/A * details. It is intended for users who want more precise specification of 0N/A * formatting behavior. 0N/A * <h3><a name="summary">Summary</a></h3> 0N/A * <p> This section is intended to provide a brief overview of formatting 0N/A * concepts. For precise behavioral details, refer to the <a 0N/A * href="#detail">Details</a> section. 0N/A * <h4><a name="syntax">Format String Syntax</a></h4> 0N/A * <p> Every method which produces formatted output requires a <i>format 0N/A * string</i> and an <i>argument list</i>. The format string is a {@link 0N/A * String} which may contain fixed text and one or more embedded <i>format 0N/A * specifiers</i>. Consider the following example: 0N/A * String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c); 0N/A * </pre></blockquote> 847N/A * This format string is the first argument to the {@code format} method. It 847N/A * contains three format specifiers "{@code %1$tm}", "{@code %1$te}", and 847N/A * "{@code %1$tY}" which indicate how the arguments should be processed and 0N/A * where they should be inserted in the text. The remaining portions of the 847N/A * format string are fixed text including {@code "Dukes Birthday: "} and any 0N/A * other spaces or punctuation. 0N/A * The argument list consists of all arguments passed to the method after the 0N/A * format string. In the above example, the argument list is of size one and 847N/A * consists of the {@link java.util.Calendar Calendar} object {@code c}. 0N/A * <li> The format specifiers for general, character, and numeric types have 0N/A * the following syntax: 0N/A * %[argument_index$][flags][width][.precision]conversion 0N/A * </pre></blockquote> 0N/A * <p> The optional <i>argument_index</i> is a decimal integer indicating the 0N/A * position of the argument in the argument list. The first argument is 847N/A * referenced by "{@code 1$}", the second by "{@code 2$}", etc. 0N/A * <p> The optional <i>flags</i> is a set of characters that modify the output 0N/A * format. The set of valid flags depends on the conversion. 0N/A * <p> The optional <i>width</i> is a non-negative decimal integer indicating 0N/A * the minimum number of characters to be written to the output. 0N/A * <p> The optional <i>precision</i> is a non-negative decimal integer usually 0N/A * used to restrict the number of characters. The specific behavior depends on 0N/A * <p> The required <i>conversion</i> is a character indicating how the 0N/A * argument should be formatted. The set of valid conversions for a given 0N/A * argument depends on the argument's data type. 0N/A * <li> The format specifiers for types which are used to represents dates and 0N/A * times have the following syntax: 0N/A * %[argument_index$][flags][width]conversion 0N/A * </pre></blockquote> 0N/A * <p> The optional <i>argument_index</i>, <i>flags</i> and <i>width</i> are 0N/A * <p> The required <i>conversion</i> is a two character sequence. The first 847N/A * character is {@code 't'} or {@code 'T'}. The second character indicates 0N/A * the format to be used. These characters are similar to but not completely 847N/A * identical to those defined by GNU {@code date} and POSIX 847N/A * {@code strftime(3c)}. 0N/A * <li> The format specifiers which do not correspond to arguments have the 0N/A * %[flags][width]conversion 0N/A * </pre></blockquote> 0N/A * <p> The optional <i>flags</i> and <i>width</i> is defined as above. 0N/A * <p> The required <i>conversion</i> is a character indicating content to be 0N/A * inserted in the output. 0N/A * <h4> Conversions </h4> 0N/A * <p> Conversions are divided into the following categories: 0N/A * <li> <b>General</b> - may be applied to any argument 0N/A * <li> <b>Character</b> - may be applied to basic types which represent 847N/A * Unicode characters: {@code char}, {@link Character}, {@code byte}, {@link 847N/A * Byte}, {@code short}, and {@link Short}. This conversion may also be 847N/A * applied to the types {@code int} and {@link Integer} when {@link 847N/A * Character#isValidCodePoint} returns {@code true} 0N/A * <li> <b>Numeric</b> 847N/A * <li> <b>Integral</b> - may be applied to Java integral types: {@code byte}, 847N/A * {@link Byte}, {@code short}, {@link Short}, {@code int} and {@link 847N/A * Integer}, {@code long}, {@link Long}, and {@link java.math.BigInteger 0N/A * <li><b>Floating Point</b> - may be applied to Java floating-point types: 847N/A * {@code float}, {@link Float}, {@code double}, {@link Double}, and {@link 0N/A * java.math.BigDecimal BigDecimal} 0N/A * <li> <b>Date/Time</b> - may be applied to Java types which are capable of 847N/A * encoding a date or time: {@code long}, {@link Long}, {@link Calendar}, and 847N/A * <li> <b>Percent</b> - produces a literal {@code '%'} 0N/A * (<tt>'\u0025'</tt>) 0N/A * <li> <b>Line Separator</b> - produces the platform-specific line separator 0N/A * <p> The following table summarizes the supported conversions. Conversions 847N/A * denoted by an upper-case character (i.e. {@code 'B'}, {@code 'H'}, 847N/A * {@code 'S'}, {@code 'C'}, {@code 'X'}, {@code 'E'}, {@code 'G'}, 847N/A * {@code 'A'}, and {@code 'T'}) are the same as those for the corresponding 0N/A * lower-case conversion characters except that the result is converted to 0N/A * upper case according to the rules of the prevailing {@link java.util.Locale 0N/A * Locale}. The result is equivalent to the following invocation of {@link 0N/A * String#toUpperCase()} 0N/A * out.toUpperCase() </pre> 0N/A * <table cellpadding=5 summary="genConv"> 0N/A * <tr><th valign="bottom"> Conversion 0N/A * <th valign="bottom"> Argument Category 0N/A * <th valign="bottom"> Description 847N/A * <tr><td valign="top"> {@code 'b'}, {@code 'B'} 0N/A * <td valign="top"> general 847N/A * <td> If the argument <i>arg</i> is {@code null}, then the result is 847N/A * "{@code false}". If <i>arg</i> is a {@code boolean} or {@link 0N/A * Boolean}, then the result is the string returned by {@link 0N/A * String#valueOf(boolean) String.valueOf(arg)}. Otherwise, the result is 847N/A * <tr><td valign="top"> {@code 'h'}, {@code 'H'} 0N/A * <td valign="top"> general 847N/A * <td> If the argument <i>arg</i> is {@code null}, then the result is 847N/A * "{@code null}". Otherwise, the result is obtained by invoking 847N/A * {@code Integer.toHexString(arg.hashCode())}. 847N/A * <tr><td valign="top"> {@code 's'}, {@code 'S'} 0N/A * <td valign="top"> general 847N/A * <td> If the argument <i>arg</i> is {@code null}, then the result is 847N/A * "{@code null}". If <i>arg</i> implements {@link Formattable}, then 0N/A * {@link Formattable#formatTo arg.formatTo} is invoked. Otherwise, the 847N/A * result is obtained by invoking {@code arg.toString()}. 847N/A * <tr><td valign="top">{@code 'c'}, {@code 'C'} 0N/A * <td valign="top"> character 0N/A * <td> The result is a Unicode character 847N/A * <tr><td valign="top">{@code 'd'} 0N/A * <td valign="top"> integral 0N/A * <td> The result is formatted as a decimal integer 847N/A * <tr><td valign="top">{@code 'o'} 0N/A * <td valign="top"> integral 0N/A * <td> The result is formatted as an octal integer 847N/A * <tr><td valign="top">{@code 'x'}, {@code 'X'} 0N/A * <td valign="top"> integral 0N/A * <td> The result is formatted as a hexadecimal integer 847N/A * <tr><td valign="top">{@code 'e'}, {@code 'E'} 0N/A * <td valign="top"> floating point 0N/A * <td> The result is formatted as a decimal number in computerized 0N/A * scientific notation 847N/A * <tr><td valign="top">{@code 'f'} 0N/A * <td valign="top"> floating point 0N/A * <td> The result is formatted as a decimal number 847N/A * <tr><td valign="top">{@code 'g'}, {@code 'G'} 0N/A * <td valign="top"> floating point 0N/A * <td> The result is formatted using computerized scientific notation or 0N/A * decimal format, depending on the precision and the value after rounding. 847N/A * <tr><td valign="top">{@code 'a'}, {@code 'A'} 0N/A * <td valign="top"> floating point 0N/A * <td> The result is formatted as a hexadecimal floating-point number with 0N/A * a significand and an exponent 847N/A * <tr><td valign="top">{@code 't'}, {@code 'T'} 0N/A * <td> Prefix for date and time conversion characters. See <a 847N/A * <tr><td valign="top">{@code '%'} 0N/A * <td valign="top"> percent 847N/A * <td> The result is a literal {@code '%'} (<tt>'\u0025'</tt>) 847N/A * <tr><td valign="top">{@code 'n'} 0N/A * <td valign="top"> line separator 0N/A * <td> The result is the platform-specific line separator 0N/A * <p> Any characters not explicitly defined as conversions are illegal and are 0N/A * reserved for future extensions. 0N/A * <p> The following date and time conversion suffix characters are defined for 847N/A * the {@code 't'} and {@code 'T'} conversions. The types are similar to but 847N/A * not completely identical to those defined by GNU {@code date} and POSIX 847N/A * {@code strftime(3c)}. Additional conversion types are provided to access 847N/A * Java-specific functionality (e.g. {@code 'L'} for milliseconds within the 0N/A * <p> The following conversion characters are used for formatting times: 0N/A * <table cellpadding=5 summary="time"> 847N/A * <tr><td valign="top"> {@code 'H'} 0N/A * <td> Hour of the day for the 24-hour clock, formatted as two digits with 847N/A * a leading zero as necessary i.e. {@code 00 - 23}. 847N/A * <tr><td valign="top">{@code 'I'} 0N/A * <td> Hour for the 12-hour clock, formatted as two digits with a leading 847N/A * zero as necessary, i.e. {@code 01 - 12}. 847N/A * <tr><td valign="top">{@code 'k'} 847N/A * <td> Hour of the day for the 24-hour clock, i.e. {@code 0 - 23}. 847N/A * <tr><td valign="top">{@code 'l'} 847N/A * <td> Hour for the 12-hour clock, i.e. {@code 1 - 12}. 847N/A * <tr><td valign="top">{@code 'M'} 0N/A * <td> Minute within the hour formatted as two digits with a leading zero 847N/A * as necessary, i.e. {@code 00 - 59}. 847N/A * <tr><td valign="top">{@code 'S'} 0N/A * <td> Seconds within the minute, formatted as two digits with a leading 847N/A * zero as necessary, i.e. {@code 00 - 60} ("{@code 60}" is a special 0N/A * value required to support leap seconds). 847N/A * <tr><td valign="top">{@code 'L'} 0N/A * <td> Millisecond within the second formatted as three digits with 847N/A * leading zeros as necessary, i.e. {@code 000 - 999}. 847N/A * <tr><td valign="top">{@code 'N'} 0N/A * <td> Nanosecond within the second, formatted as nine digits with leading 847N/A * zeros as necessary, i.e. {@code 000000000 - 999999999}. 847N/A * <tr><td valign="top">{@code 'p'} 0N/A * <td> Locale-specific {@linkplain 0N/A * java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker 847N/A * in lower case, e.g."{@code am}" or "{@code pm}". Use of the conversion 847N/A * prefix {@code 'T'} forces this output to upper case. 847N/A * <tr><td valign="top">{@code 'z'} 847N/A * style numeric time zone offset from GMT, e.g. {@code -0800}. This 0N/A * value will be adjusted as necessary for Daylight Saving Time. For 847N/A * {@code long}, {@link Long}, and {@link Date} the time zone used is 847N/A * the {@linkplain TimeZone#getDefault() default time zone} for this 0N/A * instance of the Java virtual machine. 847N/A * <tr><td valign="top">{@code 'Z'} 0N/A * <td> A string representing the abbreviation for the time zone. This 0N/A * value will be adjusted as necessary for Daylight Saving Time. For 847N/A * {@code long}, {@link Long}, and {@link Date} the time zone used is 847N/A * the {@linkplain TimeZone#getDefault() default time zone} for this 0N/A * instance of the Java virtual machine. The Formatter's locale will 0N/A * supersede the locale of the argument (if any). 847N/A * <tr><td valign="top">{@code 's'} 0N/A * <td> Seconds since the beginning of the epoch starting at 1 January 1970 847N/A * {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000} to 847N/A * {@code Long.MAX_VALUE/1000}. 847N/A * <tr><td valign="top">{@code 'Q'} 0N/A * <td> Milliseconds since the beginning of the epoch starting at 1 January 847N/A * 1970 {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE} to 847N/A * {@code Long.MAX_VALUE}. 0N/A * <p> The following conversion characters are used for formatting dates: 0N/A * <table cellpadding=5 summary="date"> 847N/A * <tr><td valign="top">{@code 'B'} 0N/A * <td> Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths 847N/A * full month name}, e.g. {@code "January"}, {@code "February"}. 847N/A * <tr><td valign="top">{@code 'b'} 0N/A * <td> Locale-specific {@linkplain 0N/A * java.text.DateFormatSymbols#getShortMonths abbreviated month name}, 847N/A * e.g. {@code "Jan"}, {@code "Feb"}. 847N/A * <tr><td valign="top">{@code 'h'} 847N/A * <td> Same as {@code 'b'}. 847N/A * <tr><td valign="top">{@code 'A'} 0N/A * <td> Locale-specific full name of the {@linkplain 0N/A * java.text.DateFormatSymbols#getWeekdays day of the week}, 847N/A * e.g. {@code "Sunday"}, {@code "Monday"} 847N/A * <tr><td valign="top">{@code 'a'} 0N/A * <td> Locale-specific short name of the {@linkplain 0N/A * java.text.DateFormatSymbols#getShortWeekdays day of the week}, 847N/A * e.g. {@code "Sun"}, {@code "Mon"} 847N/A * <tr><td valign="top">{@code 'C'} 847N/A * <td> Four-digit year divided by {@code 100}, formatted as two digits 847N/A * with leading zero as necessary, i.e. {@code 00 - 99} 847N/A * <tr><td valign="top">{@code 'Y'} 0N/A * <td> Year, formatted as at least four digits with leading zeros as 847N/A * necessary, e.g. {@code 0092} equals {@code 92} CE for the Gregorian 847N/A * <tr><td valign="top">{@code 'y'} 0N/A * <td> Last two digits of the year, formatted with leading zeros as 847N/A * necessary, i.e. {@code 00 - 99}. 847N/A * <tr><td valign="top">{@code 'j'} 0N/A * <td> Day of year, formatted as three digits with leading zeros as 847N/A * necessary, e.g. {@code 001 - 366} for the Gregorian calendar. 847N/A * <tr><td valign="top">{@code 'm'} 0N/A * <td> Month, formatted as two digits with leading zeros as necessary, 847N/A * i.e. {@code 01 - 13}. 847N/A * <tr><td valign="top">{@code 'd'} 0N/A * <td> Day of month, formatted as two digits with leading zeros as 847N/A * necessary, i.e. {@code 01 - 31} 847N/A * <tr><td valign="top">{@code 'e'} 847N/A * <td> Day of month, formatted as two digits, i.e. {@code 1 - 31}. 0N/A * <p> The following conversion characters are used for formatting common 0N/A * <table cellpadding=5 summary="composites"> 847N/A * <tr><td valign="top">{@code 'R'} 847N/A * <td> Time formatted for the 24-hour clock as {@code "%tH:%tM"} 847N/A * <tr><td valign="top">{@code 'T'} 847N/A * <td> Time formatted for the 24-hour clock as {@code "%tH:%tM:%tS"}. 847N/A * <tr><td valign="top">{@code 'r'} 847N/A * <td> Time formatted for the 12-hour clock as {@code "%tI:%tM:%tS %Tp"}. 847N/A * The location of the morning or afternoon marker ({@code '%Tp'}) may be 847N/A * <tr><td valign="top">{@code 'D'} 847N/A * <td> Date formatted as {@code "%tm/%td/%ty"}. 847N/A * <tr><td valign="top">{@code 'F'} 847N/A * complete date formatted as {@code "%tY-%tm-%td"}. 847N/A * <tr><td valign="top">{@code 'c'} 847N/A * <td> Date and time formatted as {@code "%ta %tb %td %tT %tZ %tY"}, 847N/A * e.g. {@code "Sun Jul 20 16:17:00 EDT 1969"}. 0N/A * <p> Any characters not explicitly defined as date/time conversion suffixes 0N/A * are illegal and are reserved for future extensions. 0N/A * <p> The following table summarizes the supported flags. <i>y</i> means the 0N/A * flag is supported for the indicated argument types. 0N/A * <table cellpadding=5 summary="genConv"> 0N/A * <tr><th valign="bottom"> Flag <th valign="bottom"> General 0N/A * <th valign="bottom"> Character <th valign="bottom"> Integral 0N/A * <th valign="bottom"> Floating Point 0N/A * <th valign="bottom"> Description 0N/A * <tr><td> '-' <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> y 0N/A * <td> The result will be left-justified. 0N/A * <tr><td> '#' <td align="center" valign="top"> y<sup>1</sup> 0N/A * <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> y<sup>3</sup> 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> - 0N/A * <td> The result should use a conversion-dependent alternate form 0N/A * <tr><td> '+' <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> y<sup>4</sup> 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> - 0N/A * <td> The result will always include a sign 0N/A * <tr><td> ' ' <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> y<sup>4</sup> 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> - 0N/A * <td> The result will include a leading space for positive values 0N/A * <tr><td> '0' <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> y 0N/A * <td align="center" valign="top"> - 0N/A * <td> The result will be zero-padded 0N/A * <tr><td> ',' <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> y<sup>2</sup> 0N/A * <td align="center" valign="top"> y<sup>5</sup> 0N/A * <td align="center" valign="top"> - 0N/A * <td> The result will include locale-specific {@linkplain 0N/A * java.text.DecimalFormatSymbols#getGroupingSeparator grouping separators} 0N/A * <tr><td> '(' <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> - 0N/A * <td align="center" valign="top"> y<sup>4</sup> 0N/A * <td align="center" valign="top"> y<sup>5</sup> 0N/A * <td align="center"> - 0N/A * <td> The result will enclose negative numbers in parentheses 0N/A * <p> <sup>1</sup> Depends on the definition of {@link Formattable}. 847N/A * <p> <sup>2</sup> For {@code 'd'} conversion only. 847N/A * <p> <sup>3</sup> For {@code 'o'}, {@code 'x'}, and {@code 'X'} 847N/A * <p> <sup>4</sup> For {@code 'd'}, {@code 'o'}, {@code 'x'}, and 847N/A * {@code 'X'} conversions applied to {@link java.math.BigInteger BigInteger} 847N/A * or {@code 'd'} applied to {@code byte}, {@link Byte}, {@code short}, {@link 847N/A * Short}, {@code int} and {@link Integer}, {@code long}, and {@link Long}. 847N/A * <p> <sup>5</sup> For {@code 'e'}, {@code 'E'}, {@code 'f'}, 847N/A * {@code 'g'}, and {@code 'G'} conversions only. 0N/A * <p> Any characters not explicitly defined as flags are illegal and are 0N/A * reserved for future extensions. 0N/A * <p> The width is the minimum number of characters to be written to the 0N/A * output. For the line separator conversion, width is not applicable; if it 0N/A * is provided, an exception will be thrown. 0N/A * <h4> Precision </h4> 0N/A * <p> For general argument types, the precision is the maximum number of 0N/A * characters to be written to the output. 847N/A * <p> For the floating-point conversions {@code 'e'}, {@code 'E'}, and 847N/A * {@code 'f'} the precision is the number of digits after the decimal 847N/A * separator. If the conversion is {@code 'g'} or {@code 'G'}, then the 0N/A * precision is the total number of digits in the resulting magnitude after 847N/A * rounding. If the conversion is {@code 'a'} or {@code 'A'}, then the 0N/A * precision must not be specified. 0N/A * <p> For character, integral, and date/time argument types and the percent 0N/A * and line separator conversions, the precision is not applicable; if a 0N/A * precision is provided, an exception will be thrown. 0N/A * <h4> Argument Index </h4> 0N/A * <p> The argument index is a decimal integer indicating the position of the 0N/A * argument in the argument list. The first argument is referenced by 847N/A * "{@code 1$}", the second by "{@code 2$}", etc. 0N/A * <p> Another way to reference arguments by position is to use the 847N/A * {@code '<'} (<tt>'\u003c'</tt>) flag, which causes the argument for 0N/A * the previous format specifier to be re-used. For example, the following two 0N/A * statements would produce identical strings: 0N/A * String s1 = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c); 0N/A * String s2 = String.format("Duke's Birthday: %1$tm %<te,%<tY", c); 0N/A * </pre></blockquote> 0N/A * <h3><a name="detail">Details</a></h3> 0N/A * <p> This section is intended to provide behavioral details for formatting, 0N/A * including conditions and exceptions, supported data types, localization, and 0N/A * interactions between flags, conversions, and data types. For an overview of 0N/A * formatting concepts, refer to the <a href="#summary">Summary</a> 0N/A * <p> Any characters not explicitly defined as conversions, date/time 0N/A * conversion suffixes, or flags are illegal and are reserved for 0N/A * future extensions. Use of such a character in a format string will 0N/A * cause an {@link UnknownFormatConversionException} or {@link 0N/A * UnknownFormatFlagsException} to be thrown. 0N/A * <p> If the format specifier contains a width or precision with an invalid 0N/A * value or which is otherwise unsupported, then a {@link 0N/A * IllegalFormatWidthException} or {@link IllegalFormatPrecisionException} 0N/A * respectively will be thrown. 0N/A * <p> If a format specifier contains a conversion character that is not 0N/A * applicable to the corresponding argument, then an {@link 0N/A * IllegalFormatConversionException} will be thrown. 847N/A * <p> All specified exceptions may be thrown by any of the {@code format} 847N/A * methods of {@code Formatter} as well as by any {@code format} convenience 0N/A * methods such as {@link String#format(String,Object...) String.format} and 0N/A * {@link java.io.PrintStream#printf(String,Object...) PrintStream.printf}. 847N/A * <p> Conversions denoted by an upper-case character (i.e. {@code 'B'}, 847N/A * {@code 'H'}, {@code 'S'}, {@code 'C'}, {@code 'X'}, {@code 'E'}, 847N/A * {@code 'G'}, {@code 'A'}, and {@code 'T'}) are the same as those for the 0N/A * corresponding lower-case conversion characters except that the result is 0N/A * converted to upper case according to the rules of the prevailing {@link 0N/A * java.util.Locale Locale}. The result is equivalent to the following 0N/A * invocation of {@link String#toUpperCase()} 0N/A * out.toUpperCase() </pre> 0N/A * <h4><a name="dgen">General</a></h4> 0N/A * <p> The following general conversions may be applied to any argument type: 0N/A * <table cellpadding=5 summary="dgConv"> 847N/A * <tr><td valign="top"> {@code 'b'} 0N/A * <td valign="top"> <tt>'\u0062'</tt> 847N/A * <td> Produces either "{@code true}" or "{@code false}" as returned by 0N/A * {@link Boolean#toString(boolean)}. 847N/A * <p> If the argument is {@code null}, then the result is 847N/A * "{@code false}". If the argument is a {@code boolean} or {@link 0N/A * Boolean}, then the result is the string returned by {@link 0N/A * String#valueOf(boolean) String.valueOf()}. Otherwise, the result is 847N/A * <p> If the {@code '#'} flag is given, then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'B'} 0N/A * <td valign="top"> <tt>'\u0042'</tt> 847N/A * <td> The upper-case variant of {@code 'b'}. 847N/A * <tr><td valign="top"> {@code 'h'} 0N/A * <td valign="top"> <tt>'\u0068'</tt> 0N/A * <td> Produces a string representing the hash code value of the object. 847N/A * <p> If the argument, <i>arg</i> is {@code null}, then the 847N/A * result is "{@code null}". Otherwise, the result is obtained 847N/A * by invoking {@code Integer.toHexString(arg.hashCode())}. 847N/A * <p> If the {@code '#'} flag is given, then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'H'} 0N/A * <td valign="top"> <tt>'\u0048'</tt> 847N/A * <td> The upper-case variant of {@code 'h'}. 847N/A * <tr><td valign="top"> {@code 's'} 0N/A * <td valign="top"> <tt>'\u0073'</tt> 0N/A * <td> Produces a string. 847N/A * <p> If the argument is {@code null}, then the result is 847N/A * "{@code null}". If the argument implements {@link Formattable}, then 0N/A * its {@link Formattable#formatTo formatTo} method is invoked. 0N/A * Otherwise, the result is obtained by invoking the argument's 847N/A * {@code toString()} method. 847N/A * <p> If the {@code '#'} flag is given and the argument is not a {@link 0N/A * Formattable} , then a {@link FormatFlagsConversionMismatchException} 847N/A * <tr><td valign="top"> {@code 'S'} 0N/A * <td valign="top"> <tt>'\u0053'</tt> 847N/A * <td> The upper-case variant of {@code 's'}. 0N/A * <p> The following <a name="dFlags">flags</a> apply to general conversions: 0N/A * <table cellpadding=5 summary="dFlags"> 847N/A * <tr><td valign="top"> {@code '-'} 0N/A * <td valign="top"> <tt>'\u002d'</tt> 0N/A * <td> Left justifies the output. Spaces (<tt>'\u0020'</tt>) will be 0N/A * added at the end of the converted value as required to fill the minimum 0N/A * width of the field. If the width is not provided, then a {@link 0N/A * MissingFormatWidthException} will be thrown. If this flag is not given 0N/A * then the output will be right-justified. 847N/A * <tr><td valign="top"> {@code '#'} 0N/A * <td valign="top"> <tt>'\u0023'</tt> 0N/A * <td> Requires the output use an alternate form. The definition of the 0N/A * form is specified by the conversion. 0N/A * <p> The <a name="genWidth">width</a> is the minimum number of characters to 0N/A * output. If the length of the converted value is less than the width then 847N/A * the output will be padded by <tt>' '</tt> (<tt>'\u0020'</tt>) 0N/A * until the total number of characters equals the width. The padding is on 847N/A * the left by default. If the {@code '-'} flag is given, then the padding 0N/A * will be on the right. If the width is not specified then there is no 0N/A * <p> The precision is the maximum number of characters to be written to the 0N/A * output. The precision is applied before the width, thus the output will be 847N/A * truncated to {@code precision} characters even if the width is greater than 0N/A * the precision. If the precision is not specified then there is no explicit 0N/A * limit on the number of characters. 0N/A * <h4><a name="dchar">Character</a></h4> 847N/A * This conversion may be applied to {@code char} and {@link Character}. It 847N/A * may also be applied to the types {@code byte}, {@link Byte}, 847N/A * {@code short}, and {@link Short}, {@code int} and {@link Integer} when 847N/A * {@link Character#isValidCodePoint} returns {@code true}. If it returns 847N/A * {@code false} then an {@link IllegalFormatCodePointException} will be 0N/A * <table cellpadding=5 summary="charConv"> 847N/A * <tr><td valign="top"> {@code 'c'} 0N/A * <td valign="top"> <tt>'\u0063'</tt> 0N/A * <td> Formats the argument as a Unicode character as described in <a 847N/A * Representation</a>. This may be more than one 16-bit {@code char} in 0N/A * the case where the argument represents a supplementary character. 847N/A * <p> If the {@code '#'} flag is given, then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'C'} 0N/A * <td valign="top"> <tt>'\u0043'</tt> 847N/A * <td> The upper-case variant of {@code 'c'}. 847N/A * <p> The {@code '-'} flag defined for <a href="#dFlags">General 847N/A * conversions</a> applies. If the {@code '#'} flag is given, then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 0N/A * <p> The width is defined as for <a href="#genWidth">General conversions</a>. 0N/A * <p> The precision is not applicable. If the precision is specified then an 0N/A * {@link IllegalFormatPrecisionException} will be thrown. 0N/A * <h4><a name="dnum">Numeric</a></h4> 0N/A * <p> Numeric conversions are divided into the following categories: 0N/A * <li> <a href="#dnint"><b>Byte, Short, Integer, and Long</b></a> 0N/A * <li> <a href="#dnbint"><b>BigInteger</b></a> 0N/A * <li> <a href="#dndec"><b>Float and Double</b></a> 4226N/A * <li> <a href="#dnbdec"><b>BigDecimal</b></a> 0N/A * <p> Numeric types will be formatted according to the following algorithm: 0N/A * <p><b><a name="l10n algorithm"> Number Localization Algorithm</a></b> 0N/A * <p> After digits are obtained for the integer part, fractional part, and 0N/A * exponent (as appropriate for the data type), the following transformation 0N/A * <li> Each digit character <i>d</i> in the string is replaced by a 0N/A * locale-specific digit computed relative to the current locale's 0N/A * {@linkplain java.text.DecimalFormatSymbols#getZeroDigit() zero digit} 847N/A * <i>z</i>; that is <i>d - </i> {@code '0'} 0N/A * <i> + z</i>. 0N/A * <li> If a decimal separator is present, a locale-specific {@linkplain 0N/A * java.text.DecimalFormatSymbols#getDecimalSeparator decimal separator} is 847N/A * <li> If the {@code ','} (<tt>'\u002c'</tt>) 0N/A * <a name="l10n group">flag</a> is given, then the locale-specific {@linkplain 0N/A * java.text.DecimalFormatSymbols#getGroupingSeparator grouping separator} is 0N/A * inserted by scanning the integer part of the string from least significant 0N/A * to most significant digits and inserting a separator at intervals defined by 0N/A * the locale's {@linkplain java.text.DecimalFormat#getGroupingSize() grouping 847N/A * <li> If the {@code '0'} flag is given, then the locale-specific {@linkplain 0N/A * java.text.DecimalFormatSymbols#getZeroDigit() zero digits} are inserted 0N/A * after the sign character, if any, and before the first non-zero digit, until 0N/A * the length of the string is equal to the requested field width. 847N/A * <li> If the value is negative and the {@code '('} flag is given, then a 847N/A * {@code '('} (<tt>'\u0028'</tt>) is prepended and a {@code ')'} 0N/A * (<tt>'\u0029'</tt>) is appended. 0N/A * <li> If the value is negative (or floating-point negative zero) and 847N/A * {@code '('} flag is not given, then a {@code '-'} (<tt>'\u002d'</tt>) 847N/A * <li> If the {@code '+'} flag is given and the value is positive or zero (or 847N/A * floating-point positive zero), then a {@code '+'} (<tt>'\u002b'</tt>) 0N/A * will be prepended. 0N/A * <p> If the value is NaN or positive infinity the literal strings "NaN" or 0N/A * "Infinity" respectively, will be output. If the value is negative infinity, 847N/A * then the output will be "(Infinity)" if the {@code '('} flag is given 0N/A * otherwise the output will be "-Infinity". These values are not localized. 0N/A * <p><a name="dnint"><b> Byte, Short, Integer, and Long </b></a> 847N/A * <p> The following conversions may be applied to {@code byte}, {@link Byte}, 847N/A * {@code short}, {@link Short}, {@code int} and {@link Integer}, 847N/A * {@code long}, and {@link Long}. 0N/A * <table cellpadding=5 summary="IntConv"> 847N/A * <tr><td valign="top"> {@code 'd'} 0N/A * <td valign="top"> <tt>'\u0054'</tt> 0N/A * <td> Formats the argument as a decimal integer. The <a 0N/A * href="#l10n algorithm">localization algorithm</a> is applied. 847N/A * <p> If the {@code '0'} flag is given and the value is negative, then 0N/A * the zero padding will occur after the sign. 847N/A * <p> If the {@code '#'} flag is given then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'o'} 0N/A * <td valign="top"> <tt>'\u006f'</tt> 0N/A * <td> Formats the argument as an integer in base eight. No localization 0N/A * <p> If <i>x</i> is negative then the result will be an unsigned value 847N/A * generated by adding 2<sup>n</sup> to the value where {@code n} is the 847N/A * number of bits in the type as returned by the static {@code SIZE} field 0N/A * in the {@linkplain Byte#SIZE Byte}, {@linkplain Short#SIZE Short}, 0N/A * {@linkplain Integer#SIZE Integer}, or {@linkplain Long#SIZE Long} 0N/A * classes as appropriate. 847N/A * <p> If the {@code '#'} flag is given then the output will always begin 847N/A * with the radix indicator {@code '0'}. 847N/A * <p> If the {@code '0'} flag is given then the output will be padded 0N/A * with leading zeros to the field width following any indication of sign. 847N/A * <p> If {@code '('}, {@code '+'}, '  ', or {@code ','} flags 0N/A * are given then a {@link FormatFlagsConversionMismatchException} will be 847N/A * <tr><td valign="top"> {@code 'x'} 0N/A * <td valign="top"> <tt>'\u0078'</tt> 0N/A * <td> Formats the argument as an integer in base sixteen. No 0N/A * localization is applied. 0N/A * <p> If <i>x</i> is negative then the result will be an unsigned value 847N/A * generated by adding 2<sup>n</sup> to the value where {@code n} is the 847N/A * number of bits in the type as returned by the static {@code SIZE} field 0N/A * in the {@linkplain Byte#SIZE Byte}, {@linkplain Short#SIZE Short}, 0N/A * {@linkplain Integer#SIZE Integer}, or {@linkplain Long#SIZE Long} 0N/A * classes as appropriate. 847N/A * <p> If the {@code '#'} flag is given then the output will always begin 847N/A * with the radix indicator {@code "0x"}. 847N/A * <p> If the {@code '0'} flag is given then the output will be padded to 0N/A * the field width with leading zeros after the radix indicator or sign (if 847N/A * <p> If {@code '('}, <tt>' '</tt>, {@code '+'}, or 847N/A * {@code ','} flags are given then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'X'} 0N/A * <td valign="top"> <tt>'\u0058'</tt> 847N/A * <td> The upper-case variant of {@code 'x'}. The entire string 0N/A * representing the number will be converted to {@linkplain 847N/A * String#toUpperCase upper case} including the {@code 'x'} (if any) and 847N/A * all hexadecimal digits {@code 'a'} - {@code 'f'} 0N/A * (<tt>'\u0061'</tt> - <tt>'\u0066'</tt>). 847N/A * <p> If the conversion is {@code 'o'}, {@code 'x'}, or {@code 'X'} and 847N/A * both the {@code '#'} and the {@code '0'} flags are given, then result will 847N/A * contain the radix indicator ({@code '0'} for octal and {@code "0x"} or 847N/A * {@code "0X"} for hexadecimal), some number of zeros (based on the width), 847N/A * <p> If the {@code '-'} flag is not given, then the space padding will occur 0N/A * <p> The following <a name="intFlags">flags</a> apply to numeric integral 0N/A * <table cellpadding=5 summary="intFlags"> 847N/A * <tr><td valign="top"> {@code '+'} 0N/A * <td valign="top"> <tt>'\u002b'</tt> 0N/A * <td> Requires the output to include a positive sign for all positive 0N/A * numbers. If this flag is not given then only negative values will 847N/A * <p> If both the {@code '+'} and <tt>' '</tt> flags are given 0N/A * then an {@link IllegalFormatFlagsException} will be thrown. 0N/A * <tr><td valign="top"> <tt>' '</tt> 0N/A * <td valign="top"> <tt>'\u0020'</tt> 0N/A * <td> Requires the output to include a single extra space 0N/A * (<tt>'\u0020'</tt>) for non-negative values. 847N/A * <p> If both the {@code '+'} and <tt>' '</tt> flags are given 0N/A * then an {@link IllegalFormatFlagsException} will be thrown. 847N/A * <tr><td valign="top"> {@code '0'} 0N/A * <td valign="top"> <tt>'\u0030'</tt> 0N/A * <td> Requires the output to be padded with leading {@linkplain 0N/A * java.text.DecimalFormatSymbols#getZeroDigit zeros} to the minimum field 0N/A * width following any sign or radix indicator except when converting NaN 0N/A * or infinity. If the width is not provided, then a {@link 0N/A * MissingFormatWidthException} will be thrown. 847N/A * <p> If both the {@code '-'} and {@code '0'} flags are given then an 0N/A * {@link IllegalFormatFlagsException} will be thrown. 847N/A * <tr><td valign="top"> {@code ','} 0N/A * <td valign="top"> <tt>'\u002c'</tt> 0N/A * <td> Requires the output to include the locale-specific {@linkplain 0N/A * java.text.DecimalFormatSymbols#getGroupingSeparator group separators} as 0N/A * described in the <a href="#l10n group">"group" section</a> of the 0N/A * localization algorithm. 847N/A * <tr><td valign="top"> {@code '('} 0N/A * <td valign="top"> <tt>'\u0028'</tt> 847N/A * <td> Requires the output to prepend a {@code '('} 847N/A * (<tt>'\u0028'</tt>) and append a {@code ')'} 0N/A * (<tt>'\u0029'</tt>) to negative values. 0N/A * <p> If no <a name="intdFlags">flags</a> are given the default formatting is 847N/A * <li> The output is right-justified within the {@code width} 847N/A * <li> Negative numbers begin with a {@code '-'} (<tt>'\u002d'</tt>) 0N/A * <li> Positive numbers and zero do not include a sign or extra leading 0N/A * <li> No grouping separators are included 0N/A * <p> The <a name="intWidth">width</a> is the minimum number of characters to 0N/A * be written to the output. This includes any signs, digits, grouping 0N/A * separators, radix indicator, and parentheses. If the length of the 0N/A * converted value is less than the width then the output will be padded by 0N/A * spaces (<tt>'\u0020'</tt>) until the total number of characters equals 847N/A * width. The padding is on the left by default. If {@code '-'} flag is 0N/A * given then the padding will be on the right. If width is not specified then 0N/A * there is no minimum. 0N/A * <p> The precision is not applicable. If precision is specified then an 0N/A * {@link IllegalFormatPrecisionException} will be thrown. 0N/A * <p><a name="dnbint"><b> BigInteger </b></a> 0N/A * <p> The following conversions may be applied to {@link 0N/A * java.math.BigInteger}. 0N/A * <table cellpadding=5 summary="BIntConv"> 847N/A * <tr><td valign="top"> {@code 'd'} 0N/A * <td valign="top"> <tt>'\u0054'</tt> 0N/A * <td> Requires the output to be formatted as a decimal integer. The <a 0N/A * href="#l10n algorithm">localization algorithm</a> is applied. 847N/A * <p> If the {@code '#'} flag is given {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'o'} 0N/A * <td valign="top"> <tt>'\u006f'</tt> 0N/A * <td> Requires the output to be formatted as an integer in base eight. 0N/A * No localization is applied. 0N/A * <p> If <i>x</i> is negative then the result will be a signed value 847N/A * beginning with {@code '-'} (<tt>'\u002d'</tt>). Signed output is 0N/A * allowed for this type because unlike the primitive types it is not 0N/A * possible to create an unsigned equivalent without assuming an explicit 847N/A * <p> If <i>x</i> is positive or zero and the {@code '+'} flag is given 847N/A * then the result will begin with {@code '+'} (<tt>'\u002b'</tt>). 847N/A * <p> If the {@code '#'} flag is given then the output will always begin 847N/A * with {@code '0'} prefix. 847N/A * <p> If the {@code '0'} flag is given then the output will be padded 0N/A * with leading zeros to the field width following any indication of sign. 847N/A * <p> If the {@code ','} flag is given then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'x'} 0N/A * <td valign="top"> <tt>'\u0078'</tt> 0N/A * <td> Requires the output to be formatted as an integer in base 0N/A * sixteen. No localization is applied. 0N/A * <p> If <i>x</i> is negative then the result will be a signed value 847N/A * beginning with {@code '-'} (<tt>'\u002d'</tt>). Signed output is 0N/A * allowed for this type because unlike the primitive types it is not 0N/A * possible to create an unsigned equivalent without assuming an explicit 847N/A * <p> If <i>x</i> is positive or zero and the {@code '+'} flag is given 847N/A * then the result will begin with {@code '+'} (<tt>'\u002b'</tt>). 847N/A * <p> If the {@code '#'} flag is given then the output will always begin 847N/A * with the radix indicator {@code "0x"}. 847N/A * <p> If the {@code '0'} flag is given then the output will be padded to 0N/A * the field width with leading zeros after the radix indicator or sign (if 847N/A * <p> If the {@code ','} flag is given then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'X'} 0N/A * <td valign="top"> <tt>'\u0058'</tt> 847N/A * <td> The upper-case variant of {@code 'x'}. The entire string 0N/A * representing the number will be converted to {@linkplain 847N/A * String#toUpperCase upper case} including the {@code 'x'} (if any) and 847N/A * all hexadecimal digits {@code 'a'} - {@code 'f'} 0N/A * (<tt>'\u0061'</tt> - <tt>'\u0066'</tt>). 847N/A * <p> If the conversion is {@code 'o'}, {@code 'x'}, or {@code 'X'} and 847N/A * both the {@code '#'} and the {@code '0'} flags are given, then result will 847N/A * contain the base indicator ({@code '0'} for octal and {@code "0x"} or 847N/A * {@code "0X"} for hexadecimal), some number of zeros (based on the width), 847N/A * <p> If the {@code '0'} flag is given and the value is negative, then the 0N/A * zero padding will occur after the sign. 847N/A * <p> If the {@code '-'} flag is not given, then the space padding will occur 0N/A * <p> All <a href="#intFlags">flags</a> defined for Byte, Short, Integer, and 0N/A * Long apply. The <a href="#intdFlags">default behavior</a> when no flags are 0N/A * given is the same as for Byte, Short, Integer, and Long. 0N/A * <p> The specification of <a href="#intWidth">width</a> is the same as 0N/A * defined for Byte, Short, Integer, and Long. 0N/A * <p> The precision is not applicable. If precision is specified then an 0N/A * {@link IllegalFormatPrecisionException} will be thrown. 0N/A * <p><a name="dndec"><b> Float and Double</b></a> 847N/A * <p> The following conversions may be applied to {@code float}, {@link 847N/A * Float}, {@code double} and {@link Double}. 0N/A * <table cellpadding=5 summary="floatConv"> 847N/A * <tr><td valign="top"> {@code 'e'} 0N/A * <td valign="top"> <tt>'\u0065'</tt> 0N/A * <td> Requires the output to be formatted using <a 0N/A * name="scientific">computerized scientific notation</a>. The <a 0N/A * href="#l10n algorithm">localization algorithm</a> is applied. 0N/A * <p> The formatting of the magnitude <i>m</i> depends upon its value. 0N/A * <p> If <i>m</i> is NaN or infinite, the literal strings "NaN" or 0N/A * "Infinity", respectively, will be output. These values are not 0N/A * <p> If <i>m</i> is positive-zero or negative-zero, then the exponent 847N/A * will be {@code "+00"}. 0N/A * <p> Otherwise, the result is a string that represents the sign and 0N/A * magnitude (absolute value) of the argument. The formatting of the sign 0N/A * is described in the <a href="#l10n algorithm">localization 0N/A * algorithm</a>. The formatting of the magnitude <i>m</i> depends upon its 0N/A * <p> Let <i>n</i> be the unique integer such that 10<sup><i>n</i></sup> 0N/A * <= <i>m</i> < 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the 0N/A * mathematically exact quotient of <i>m</i> and 10<sup><i>n</i></sup> so 0N/A * that 1 <= <i>a</i> < 10. The magnitude is then represented as the 0N/A * integer part of <i>a</i>, as a single decimal digit, followed by the 0N/A * decimal separator followed by decimal digits representing the fractional 847N/A * part of <i>a</i>, followed by the exponent symbol {@code 'e'} 0N/A * (<tt>'\u0065'</tt>), followed by the sign of the exponent, followed 0N/A * by a representation of <i>n</i> as a decimal integer, as produced by the 0N/A * method {@link Long#toString(long, int)}, and zero-padded to include at 0N/A * <p> The number of digits in the result for the fractional part of 0N/A * <i>m</i> or <i>a</i> is equal to the precision. If the precision is not 847N/A * specified then the default value is {@code 6}. If the precision is less 0N/A * than the number of digits which would appear after the decimal point in 0N/A * the string returned by {@link Float#toString(float)} or {@link 0N/A * Double#toString(double)} respectively, then the value will be rounded 0N/A * using the {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up 0N/A * algorithm}. Otherwise, zeros may be appended to reach the precision. 0N/A * For a canonical representation of the value, use {@link 0N/A * Float#toString(float)} or {@link Double#toString(double)} as 847N/A * <p>If the {@code ','} flag is given, then an {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'E'} 0N/A * <td valign="top"> <tt>'\u0045'</tt> 847N/A * <td> The upper-case variant of {@code 'e'}. The exponent symbol 847N/A * will be {@code 'E'} (<tt>'\u0045'</tt>). 847N/A * <tr><td valign="top"> {@code 'g'} 0N/A * <td valign="top"> <tt>'\u0067'</tt> 0N/A * <td> Requires the output to be formatted in general scientific notation 0N/A * as described below. The <a href="#l10n algorithm">localization 0N/A * algorithm</a> is applied. 0N/A * <p> After rounding for the precision, the formatting of the resulting 0N/A * magnitude <i>m</i> depends on its value. 0N/A * <p> If <i>m</i> is greater than or equal to 10<sup>-4</sup> but less 0N/A * than 10<sup>precision</sup> then it is represented in <i><a 0N/A * href="#decimal">decimal format</a></i>. 0N/A * <p> If <i>m</i> is less than 10<sup>-4</sup> or greater than or equal to 0N/A * 10<sup>precision</sup>, then it is represented in <i><a 0N/A * href="#scientific">computerized scientific notation</a></i>. 0N/A * <p> The total number of significant digits in <i>m</i> is equal to the 0N/A * precision. If the precision is not specified, then the default value is 847N/A * {@code 6}. If the precision is {@code 0}, then it is taken to be 847N/A * <p> If the {@code '#'} flag is given then an {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'G'} 0N/A * <td valign="top"> <tt>'\u0047'</tt> 847N/A * <td> The upper-case variant of {@code 'g'}. 847N/A * <tr><td valign="top"> {@code 'f'} 0N/A * <td valign="top"> <tt>'\u0066'</tt> 0N/A * <td> Requires the output to be formatted using <a name="decimal">decimal 0N/A * format</a>. The <a href="#l10n algorithm">localization algorithm</a> is 0N/A * <p> The result is a string that represents the sign and magnitude 0N/A * (absolute value) of the argument. The formatting of the sign is 0N/A * described in the <a href="#l10n algorithm">localization 0N/A * algorithm</a>. The formatting of the magnitude <i>m</i> depends upon its 0N/A * <p> If <i>m</i> NaN or infinite, the literal strings "NaN" or 0N/A * "Infinity", respectively, will be output. These values are not 0N/A * <p> The magnitude is formatted as the integer part of <i>m</i>, with no 0N/A * leading zeroes, followed by the decimal separator followed by one or 0N/A * more decimal digits representing the fractional part of <i>m</i>. 0N/A * <p> The number of digits in the result for the fractional part of 0N/A * <i>m</i> or <i>a</i> is equal to the precision. If the precision is not 847N/A * specified then the default value is {@code 6}. If the precision is less 0N/A * than the number of digits which would appear after the decimal point in 0N/A * the string returned by {@link Float#toString(float)} or {@link 0N/A * Double#toString(double)} respectively, then the value will be rounded 0N/A * using the {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up 0N/A * algorithm}. Otherwise, zeros may be appended to reach the precision. 806N/A * For a canonical representation of the value, use {@link 0N/A * Float#toString(float)} or {@link Double#toString(double)} as 847N/A * <tr><td valign="top"> {@code 'a'} 0N/A * <td valign="top"> <tt>'\u0061'</tt> 0N/A * <td> Requires the output to be formatted in hexadecimal exponential 0N/A * form. No localization is applied. 0N/A * <p> The result is a string that represents the sign and magnitude 0N/A * (absolute value) of the argument <i>x</i>. 0N/A * <p> If <i>x</i> is negative or a negative-zero value then the result 847N/A * will begin with {@code '-'} (<tt>'\u002d'</tt>). 0N/A * <p> If <i>x</i> is positive or a positive-zero value and the 847N/A * {@code '+'} flag is given then the result will begin with {@code '+'} 0N/A * (<tt>'\u002b'</tt>). 0N/A * <p> The formatting of the magnitude <i>m</i> depends upon its value. 0N/A * <li> If the value is NaN or infinite, the literal strings "NaN" or 0N/A * "Infinity", respectively, will be output. 0N/A * <li> If <i>m</i> is zero then it is represented by the string 847N/A * <li> If <i>m</i> is a {@code double} value with a normalized 0N/A * representation then substrings are used to represent the significand and 0N/A * exponent fields. The significand is represented by the characters 847N/A * {@code "0x1."} followed by the hexadecimal representation of the rest 0N/A * of the significand as a fraction. The exponent is represented by 847N/A * {@code 'p'} (<tt>'\u0070'</tt>) followed by a decimal string of the 0N/A * unbiased exponent as if produced by invoking {@link 0N/A * Integer#toString(int) Integer.toString} on the exponent value. 847N/A * <li> If <i>m</i> is a {@code double} value with a subnormal 0N/A * representation then the significand is represented by the characters 847N/A * {@code '0x0.'} followed by the hexadecimal representation of the rest 0N/A * of the significand as a fraction. The exponent is represented by 847N/A * {@code 'p-1022'}. Note that there must be at least one nonzero digit 0N/A * in a subnormal significand. 847N/A * <p> If the {@code '('} or {@code ','} flags are given, then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'A'} 0N/A * <td valign="top"> <tt>'\u0041'</tt> 847N/A * <td> The upper-case variant of {@code 'a'}. The entire string 0N/A * representing the number will be converted to upper case including the 847N/A * {@code 'x'} (<tt>'\u0078'</tt>) and {@code 'p'} 847N/A * (<tt>'\u0070'</tt> and all hexadecimal digits {@code 'a'} - 847N/A * {@code 'f'} (<tt>'\u0061'</tt> - <tt>'\u0066'</tt>). 0N/A * <p> All <a href="#intFlags">flags</a> defined for Byte, Short, Integer, and 847N/A * <p> If the {@code '#'} flag is given, then the decimal separator will 0N/A * always be present. 0N/A * <p> If no <a name="floatdFlags">flags</a> are given the default formatting 847N/A * <li> The output is right-justified within the {@code width} 847N/A * <li> Negative numbers begin with a {@code '-'} 0N/A * <li> Positive numbers and positive zero do not include a sign or extra 0N/A * <li> No grouping separators are included 0N/A * <li> The decimal separator will only appear if a digit follows it 0N/A * <p> The <a name="floatDWidth">width</a> is the minimum number of characters 0N/A * to be written to the output. This includes any signs, digits, grouping 0N/A * separators, decimal separators, exponential symbol, radix indicator, 0N/A * parentheses, and strings representing infinity and NaN as applicable. If 0N/A * the length of the converted value is less than the width then the output 0N/A * will be padded by spaces (<tt>'\u0020'</tt>) until the total number of 0N/A * characters equals width. The padding is on the left by default. If the 847N/A * {@code '-'} flag is given then the padding will be on the right. If width 0N/A * is not specified then there is no minimum. 847N/A * <p> If the <a name="floatDPrec">conversion</a> is {@code 'e'}, 847N/A * {@code 'E'} or {@code 'f'}, then the precision is the number of digits 0N/A * after the decimal separator. If the precision is not specified, then it is 847N/A * assumed to be {@code 6}. 847N/A * <p> If the conversion is {@code 'g'} or {@code 'G'}, then the precision is 0N/A * the total number of significant digits in the resulting magnitude after 0N/A * rounding. If the precision is not specified, then the default value is 847N/A * {@code 6}. If the precision is {@code 0}, then it is taken to be 847N/A * <p> If the conversion is {@code 'a'} or {@code 'A'}, then the precision 0N/A * is the number of hexadecimal digits after the decimal separator. If the 0N/A * precision is not provided, then all of the digits as returned by {@link 0N/A * Double#toHexString(double)} will be output. 4226N/A * <p><a name="dnbdec"><b> BigDecimal </b></a> 0N/A * <p> The following conversions may be applied {@link java.math.BigDecimal 0N/A * <table cellpadding=5 summary="floatConv"> 847N/A * <tr><td valign="top"> {@code 'e'} 0N/A * <td valign="top"> <tt>'\u0065'</tt> 0N/A * <td> Requires the output to be formatted using <a 4226N/A * name="bscientific">computerized scientific notation</a>. The <a 0N/A * href="#l10n algorithm">localization algorithm</a> is applied. 0N/A * <p> The formatting of the magnitude <i>m</i> depends upon its value. 0N/A * <p> If <i>m</i> is positive-zero or negative-zero, then the exponent 847N/A * will be {@code "+00"}. 0N/A * <p> Otherwise, the result is a string that represents the sign and 0N/A * magnitude (absolute value) of the argument. The formatting of the sign 0N/A * is described in the <a href="#l10n algorithm">localization 0N/A * algorithm</a>. The formatting of the magnitude <i>m</i> depends upon its 0N/A * <p> Let <i>n</i> be the unique integer such that 10<sup><i>n</i></sup> 0N/A * <= <i>m</i> < 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the 0N/A * mathematically exact quotient of <i>m</i> and 10<sup><i>n</i></sup> so 0N/A * that 1 <= <i>a</i> < 10. The magnitude is then represented as the 0N/A * integer part of <i>a</i>, as a single decimal digit, followed by the 0N/A * decimal separator followed by decimal digits representing the fractional 847N/A * part of <i>a</i>, followed by the exponent symbol {@code 'e'} 0N/A * (<tt>'\u0065'</tt>), followed by the sign of the exponent, followed 0N/A * by a representation of <i>n</i> as a decimal integer, as produced by the 0N/A * method {@link Long#toString(long, int)}, and zero-padded to include at 0N/A * <p> The number of digits in the result for the fractional part of 0N/A * <i>m</i> or <i>a</i> is equal to the precision. If the precision is not 847N/A * specified then the default value is {@code 6}. If the precision is 3770N/A * less than the number of digits to the right of the decimal point then 3770N/A * the value will be rounded using the 3770N/A * {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up 0N/A * algorithm}. Otherwise, zeros may be appended to reach the precision. 0N/A * For a canonical representation of the value, use {@link 0N/A * BigDecimal#toString()}. 847N/A * <p> If the {@code ','} flag is given, then an {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'E'} 0N/A * <td valign="top"> <tt>'\u0045'</tt> 847N/A * <td> The upper-case variant of {@code 'e'}. The exponent symbol 847N/A * will be {@code 'E'} (<tt>'\u0045'</tt>). 847N/A * <tr><td valign="top"> {@code 'g'} 0N/A * <td valign="top"> <tt>'\u0067'</tt> 0N/A * <td> Requires the output to be formatted in general scientific notation 0N/A * as described below. The <a href="#l10n algorithm">localization 0N/A * algorithm</a> is applied. 0N/A * <p> After rounding for the precision, the formatting of the resulting 0N/A * magnitude <i>m</i> depends on its value. 0N/A * <p> If <i>m</i> is greater than or equal to 10<sup>-4</sup> but less 0N/A * than 10<sup>precision</sup> then it is represented in <i><a 4226N/A * href="#bdecimal">decimal format</a></i>. 0N/A * <p> If <i>m</i> is less than 10<sup>-4</sup> or greater than or equal to 0N/A * 10<sup>precision</sup>, then it is represented in <i><a 4226N/A * href="#bscientific">computerized scientific notation</a></i>. 0N/A * <p> The total number of significant digits in <i>m</i> is equal to the 0N/A * precision. If the precision is not specified, then the default value is 847N/A * {@code 6}. If the precision is {@code 0}, then it is taken to be 847N/A * <p> If the {@code '#'} flag is given then an {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 847N/A * <tr><td valign="top"> {@code 'G'} 0N/A * <td valign="top"> <tt>'\u0047'</tt> 847N/A * <td> The upper-case variant of {@code 'g'}. 847N/A * <tr><td valign="top"> {@code 'f'} 0N/A * <td valign="top"> <tt>'\u0066'</tt> 4226N/A * <td> Requires the output to be formatted using <a name="bdecimal">decimal 0N/A * format</a>. The <a href="#l10n algorithm">localization algorithm</a> is 0N/A * <p> The result is a string that represents the sign and magnitude 0N/A * (absolute value) of the argument. The formatting of the sign is 0N/A * described in the <a href="#l10n algorithm">localization 0N/A * algorithm</a>. The formatting of the magnitude <i>m</i> depends upon its 0N/A * <p> The magnitude is formatted as the integer part of <i>m</i>, with no 0N/A * leading zeroes, followed by the decimal separator followed by one or 0N/A * more decimal digits representing the fractional part of <i>m</i>. 0N/A * <p> The number of digits in the result for the fractional part of 3770N/A * <i>m</i> or <i>a</i> is equal to the precision. If the precision is not 847N/A * specified then the default value is {@code 6}. If the precision is 3770N/A * less than the number of digits to the right of the decimal point 3770N/A * then the value will be rounded using the 3770N/A * {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up 0N/A * algorithm}. Otherwise, zeros may be appended to reach the precision. 0N/A * For a canonical representation of the value, use {@link 0N/A * BigDecimal#toString()}. 0N/A * <p> All <a href="#intFlags">flags</a> defined for Byte, Short, Integer, and 847N/A * <p> If the {@code '#'} flag is given, then the decimal separator will 0N/A * always be present. 0N/A * <p> The <a href="#floatdFlags">default behavior</a> when no flags are 0N/A * given is the same as for Float and Double. 0N/A * <p> The specification of <a href="#floatDWidth">width</a> and <a 0N/A * href="#floatDPrec">precision</a> is the same as defined for Float and 847N/A * <p> This conversion may be applied to {@code long}, {@link Long}, {@link 0N/A * Calendar}, and {@link Date}. 0N/A * <table cellpadding=5 summary="DTConv"> 847N/A * <tr><td valign="top"> {@code 't'} 0N/A * <td valign="top"> <tt>'\u0074'</tt> 0N/A * <td> Prefix for date and time conversion characters. 847N/A * <tr><td valign="top"> {@code 'T'} 0N/A * <td valign="top"> <tt>'\u0054'</tt> 847N/A * <td> The upper-case variant of {@code 't'}. 0N/A * <p> The following date and time conversion character suffixes are defined 847N/A * for the {@code 't'} and {@code 'T'} conversions. The types are similar to 847N/A * but not completely identical to those defined by GNU {@code date} and 847N/A * POSIX {@code strftime(3c)}. Additional conversion types are provided to 847N/A * access Java-specific functionality (e.g. {@code 'L'} for milliseconds 0N/A * within the second). 0N/A * <p> The following conversion characters are used for formatting times: 0N/A * <table cellpadding=5 summary="time"> 847N/A * <tr><td valign="top"> {@code 'H'} 0N/A * <td valign="top"> <tt>'\u0048'</tt> 0N/A * <td> Hour of the day for the 24-hour clock, formatted as two digits with 847N/A * a leading zero as necessary i.e. {@code 00 - 23}. {@code 00} 0N/A * corresponds to midnight. 847N/A * <tr><td valign="top">{@code 'I'} 0N/A * <td valign="top"> <tt>'\u0049'</tt> 0N/A * <td> Hour for the 12-hour clock, formatted as two digits with a leading 847N/A * zero as necessary, i.e. {@code 01 - 12}. {@code 01} corresponds to 0N/A * one o'clock (either morning or afternoon). 847N/A * <tr><td valign="top">{@code 'k'} 0N/A * <td valign="top"> <tt>'\u006b'</tt> 847N/A * <td> Hour of the day for the 24-hour clock, i.e. {@code 0 - 23}. 847N/A * {@code 0} corresponds to midnight. 847N/A * <tr><td valign="top">{@code 'l'} 0N/A * <td valign="top"> <tt>'\u006c'</tt> 847N/A * <td> Hour for the 12-hour clock, i.e. {@code 1 - 12}. {@code 1} 0N/A * corresponds to one o'clock (either morning or afternoon). 847N/A * <tr><td valign="top">{@code 'M'} 0N/A * <td valign="top"> <tt>'\u004d'</tt> 0N/A * <td> Minute within the hour formatted as two digits with a leading zero 847N/A * as necessary, i.e. {@code 00 - 59}. 847N/A * <tr><td valign="top">{@code 'S'} 0N/A * <td valign="top"> <tt>'\u0053'</tt> 0N/A * <td> Seconds within the minute, formatted as two digits with a leading 847N/A * zero as necessary, i.e. {@code 00 - 60} ("{@code 60}" is a special 0N/A * value required to support leap seconds). 847N/A * <tr><td valign="top">{@code 'L'} 0N/A * <td valign="top"> <tt>'\u004c'</tt> 0N/A * <td> Millisecond within the second formatted as three digits with 847N/A * leading zeros as necessary, i.e. {@code 000 - 999}. 847N/A * <tr><td valign="top">{@code 'N'} 0N/A * <td valign="top"> <tt>'\u004e'</tt> 0N/A * <td> Nanosecond within the second, formatted as nine digits with leading 847N/A * zeros as necessary, i.e. {@code 000000000 - 999999999}. The precision 0N/A * of this value is limited by the resolution of the underlying operating 0N/A * system or hardware. 847N/A * <tr><td valign="top">{@code 'p'} 0N/A * <td valign="top"> <tt>'\u0070'</tt> 0N/A * <td> Locale-specific {@linkplain 0N/A * java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker 847N/A * in lower case, e.g."{@code am}" or "{@code pm}". Use of the 847N/A * conversion prefix {@code 'T'} forces this output to upper case. (Note 847N/A * that {@code 'p'} produces lower-case output. This is different from 847N/A * GNU {@code date} and POSIX {@code strftime(3c)} which produce 0N/A * upper-case output.) 847N/A * <tr><td valign="top">{@code 'z'} 0N/A * <td valign="top"> <tt>'\u007a'</tt> 847N/A * style numeric time zone offset from GMT, e.g. {@code -0800}. This 0N/A * value will be adjusted as necessary for Daylight Saving Time. For 847N/A * {@code long}, {@link Long}, and {@link Date} the time zone used is 847N/A * the {@linkplain TimeZone#getDefault() default time zone} for this 0N/A * instance of the Java virtual machine. 847N/A * <tr><td valign="top">{@code 'Z'} 3107N/A * <td valign="top"> <tt>'\u005a'</tt> 0N/A * <td> A string representing the abbreviation for the time zone. This 0N/A * value will be adjusted as necessary for Daylight Saving Time. For 847N/A * {@code long}, {@link Long}, and {@link Date} the time zone used is 847N/A * the {@linkplain TimeZone#getDefault() default time zone} for this 0N/A * instance of the Java virtual machine. The Formatter's locale will 0N/A * supersede the locale of the argument (if any). 847N/A * <tr><td valign="top">{@code 's'} 0N/A * <td valign="top"> <tt>'\u0073'</tt> 0N/A * <td> Seconds since the beginning of the epoch starting at 1 January 1970 847N/A * {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000} to 847N/A * {@code Long.MAX_VALUE/1000}. 847N/A * <tr><td valign="top">{@code 'Q'} 0N/A * <td valign="top"> <tt>'\u004f'</tt> 0N/A * <td> Milliseconds since the beginning of the epoch starting at 1 January 847N/A * 1970 {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE} to 847N/A * {@code Long.MAX_VALUE}. The precision of this value is limited by 0N/A * the resolution of the underlying operating system or hardware. 0N/A * <p> The following conversion characters are used for formatting dates: 0N/A * <table cellpadding=5 summary="date"> 847N/A * <tr><td valign="top">{@code 'B'} 0N/A * <td valign="top"> <tt>'\u0042'</tt> 0N/A * <td> Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths 847N/A * full month name}, e.g. {@code "January"}, {@code "February"}. 847N/A * <tr><td valign="top">{@code 'b'} 0N/A * <td valign="top"> <tt>'\u0062'</tt> 0N/A * <td> Locale-specific {@linkplain 0N/A * java.text.DateFormatSymbols#getShortMonths abbreviated month name}, 847N/A * e.g. {@code "Jan"}, {@code "Feb"}. 847N/A * <tr><td valign="top">{@code 'h'} 0N/A * <td valign="top"> <tt>'\u0068'</tt> 847N/A * <td> Same as {@code 'b'}. 847N/A * <tr><td valign="top">{@code 'A'} 0N/A * <td valign="top"> <tt>'\u0041'</tt> 0N/A * <td> Locale-specific full name of the {@linkplain 0N/A * java.text.DateFormatSymbols#getWeekdays day of the week}, 847N/A * e.g. {@code "Sunday"}, {@code "Monday"} 847N/A * <tr><td valign="top">{@code 'a'} 0N/A * <td valign="top"> <tt>'\u0061'</tt> 0N/A * <td> Locale-specific short name of the {@linkplain 0N/A * java.text.DateFormatSymbols#getShortWeekdays day of the week}, 847N/A * e.g. {@code "Sun"}, {@code "Mon"} 847N/A * <tr><td valign="top">{@code 'C'} 0N/A * <td valign="top"> <tt>'\u0043'</tt> 847N/A * <td> Four-digit year divided by {@code 100}, formatted as two digits 847N/A * with leading zero as necessary, i.e. {@code 00 - 99} 847N/A * <tr><td valign="top">{@code 'Y'} 0N/A * <td valign="top"> <tt>'\u0059'</tt> <td> Year, formatted to at least 847N/A * four digits with leading zeros as necessary, e.g. {@code 0092} equals 847N/A * {@code 92} CE for the Gregorian calendar. 847N/A * <tr><td valign="top">{@code 'y'} 0N/A * <td valign="top"> <tt>'\u0079'</tt> 0N/A * <td> Last two digits of the year, formatted with leading zeros as 847N/A * necessary, i.e. {@code 00 - 99}. 847N/A * <tr><td valign="top">{@code 'j'} 0N/A * <td valign="top"> <tt>'\u006a'</tt> 0N/A * <td> Day of year, formatted as three digits with leading zeros as 847N/A * necessary, e.g. {@code 001 - 366} for the Gregorian calendar. 847N/A * {@code 001} corresponds to the first day of the year. 847N/A * <tr><td valign="top">{@code 'm'} 0N/A * <td valign="top"> <tt>'\u006d'</tt> 0N/A * <td> Month, formatted as two digits with leading zeros as necessary, 847N/A * i.e. {@code 01 - 13}, where "{@code 01}" is the first month of the 847N/A * year and ("{@code 13}" is a special value required to support lunar 847N/A * <tr><td valign="top">{@code 'd'} 0N/A * <td valign="top"> <tt>'\u0064'</tt> 0N/A * <td> Day of month, formatted as two digits with leading zeros as 847N/A * necessary, i.e. {@code 01 - 31}, where "{@code 01}" is the first day 847N/A * <tr><td valign="top">{@code 'e'} 0N/A * <td valign="top"> <tt>'\u0065'</tt> 847N/A * <td> Day of month, formatted as two digits, i.e. {@code 1 - 31} where 847N/A * "{@code 1}" is the first day of the month. 0N/A * <p> The following conversion characters are used for formatting common 0N/A * <table cellpadding=5 summary="composites"> 847N/A * <tr><td valign="top">{@code 'R'} 0N/A * <td valign="top"> <tt>'\u0052'</tt> 847N/A * <td> Time formatted for the 24-hour clock as {@code "%tH:%tM"} 847N/A * <tr><td valign="top">{@code 'T'} 0N/A * <td valign="top"> <tt>'\u0054'</tt> 847N/A * <td> Time formatted for the 24-hour clock as {@code "%tH:%tM:%tS"}. 847N/A * <tr><td valign="top">{@code 'r'} 0N/A * <td valign="top"> <tt>'\u0072'</tt> 847N/A * <td> Time formatted for the 12-hour clock as {@code "%tI:%tM:%tS 847N/A * %Tp"}. The location of the morning or afternoon marker 847N/A * ({@code '%Tp'}) may be locale-dependent. 847N/A * <tr><td valign="top">{@code 'D'} 0N/A * <td valign="top"> <tt>'\u0044'</tt> 847N/A * <td> Date formatted as {@code "%tm/%td/%ty"}. 847N/A * <tr><td valign="top">{@code 'F'} 0N/A * <td valign="top"> <tt>'\u0046'</tt> 847N/A * complete date formatted as {@code "%tY-%tm-%td"}. 847N/A * <tr><td valign="top">{@code 'c'} 0N/A * <td valign="top"> <tt>'\u0063'</tt> 847N/A * <td> Date and time formatted as {@code "%ta %tb %td %tT %tZ %tY"}, 847N/A * e.g. {@code "Sun Jul 20 16:17:00 EDT 1969"}. 847N/A * <p> The {@code '-'} flag defined for <a href="#dFlags">General 847N/A * conversions</a> applies. If the {@code '#'} flag is given, then a {@link 0N/A * FormatFlagsConversionMismatchException} will be thrown. 0N/A * <p> The <a name="dtWidth">width</a> is the minimum number of characters to 0N/A * be written to the output. If the length of the converted value is less than 847N/A * the {@code width} then the output will be padded by spaces 0N/A * (<tt>'\u0020'</tt>) until the total number of characters equals width. 847N/A * The padding is on the left by default. If the {@code '-'} flag is given 0N/A * then the padding will be on the right. If width is not specified then there 0N/A * <p> The precision is not applicable. If the precision is specified then an 0N/A * {@link IllegalFormatPrecisionException} will be thrown. 0N/A * <h4><a name="dper">Percent</a></h4> 0N/A * <p> The conversion does not correspond to any argument. 0N/A * <table cellpadding=5 summary="DTConv"> 847N/A * <tr><td valign="top">{@code '%'} 847N/A * <td> The result is a literal {@code '%'} (<tt>'\u0025'</tt>) 0N/A * <p> The <a name="dtWidth">width</a> is the minimum number of characters to 847N/A * be written to the output including the {@code '%'}. If the length of the 847N/A * converted value is less than the {@code width} then the output will be 0N/A * padded by spaces (<tt>'\u0020'</tt>) until the total number of 0N/A * characters equals width. The padding is on the left. If width is not 847N/A * specified then just the {@code '%'} is output. 847N/A * <p> The {@code '-'} flag defined for <a href="#dFlags">General 0N/A * conversions</a> applies. If any other flags are provided, then a 0N/A * {@link FormatFlagsConversionMismatchException} will be thrown. 0N/A * <p> The precision is not applicable. If the precision is specified an 0N/A * {@link IllegalFormatPrecisionException} will be thrown. 0N/A * <h4><a name="dls">Line Separator</a></h4> 0N/A * <p> The conversion does not correspond to any argument. 0N/A * <table cellpadding=5 summary="DTConv"> 847N/A * <tr><td valign="top">{@code 'n'} 0N/A * <td> the platform-specific line separator as returned by {@link 0N/A * System#getProperty System.getProperty("line.separator")}. 0N/A * <p> Flags, width, and precision are not applicable. If any are provided an 0N/A * {@link IllegalFormatFlagsException}, {@link IllegalFormatWidthException}, 0N/A * and {@link IllegalFormatPrecisionException}, respectively will be thrown. 0N/A * <h4><a name="dpos">Argument Index</a></h4> 0N/A * <p> Format specifiers can reference arguments in three ways: 0N/A * <li> <i>Explicit indexing</i> is used when the format specifier contains an 0N/A * argument index. The argument index is a decimal integer indicating the 0N/A * position of the argument in the argument list. The first argument is 847N/A * referenced by "{@code 1$}", the second by "{@code 2$}", etc. An argument 0N/A * may be referenced more than once. 0N/A * formatter.format("%4$s %3$s %2$s %1$s %4$s %3$s %2$s %1$s", 0N/A * "a", "b", "c", "d") 0N/A * // -> "d c b a d c b a" 0N/A * </pre></blockquote> 0N/A * <li> <i>Relative indexing</i> is used when the format specifier contains a 847N/A * {@code '<'} (<tt>'\u003c'</tt>) flag which causes the argument for 0N/A * the previous format specifier to be re-used. If there is no previous 0N/A * argument, then a {@link MissingFormatArgumentException} is thrown. 0N/A * formatter.format("%s %s %<s %<s", "a", "b", "c", "d") 0N/A * // -> "a b b b" 0N/A * // "c" and "d" are ignored because they are not referenced 0N/A * </pre></blockquote> 0N/A * <li> <i>Ordinary indexing</i> is used when the format specifier contains 847N/A * neither an argument index nor a {@code '<'} flag. Each format specifier 0N/A * which uses ordinary indexing is assigned a sequential implicit index into 0N/A * argument list which is independent of the indices used by explicit or 0N/A * relative indexing. 0N/A * formatter.format("%s %s %s %s", "a", "b", "c", "d") 0N/A * // -> "a b c d" 0N/A * </pre></blockquote> 0N/A * <p> It is possible to have a format string which uses all forms of indexing, 0N/A * formatter.format("%2$s %s %<s %s", "a", "b", "c", "d") 0N/A * // -> "b a a b" 0N/A * // "c" and "d" are ignored because they are not referenced 0N/A * </pre></blockquote> 0N/A * <p> The maximum number of arguments is limited by the maximum dimension of a 4008N/A * <cite>The Java™ Virtual Machine Specification</cite>. 4008N/A * If the argument index is does not correspond to an 0N/A * available argument, then a {@link MissingFormatArgumentException} is thrown. 0N/A * <p> If there are more arguments than format specifiers, the extra arguments 847N/A * <p> Unless otherwise specified, passing a {@code null} argument to any 0N/A * method or constructor in this class will cause a {@link 0N/A * NullPointerException} to be thrown. 0N/A * @author Iris Clark 0N/A // 1 (sign) + 19 (max # sig digits) + 1 ('.') + 1 ('e') + 1 (sign) 0N/A // + 3 (max # exp digits) + 4 (error) = 30 3377N/A * Returns a charset object for the given charset name. 3377N/A * @throws NullPointerException is csn is null 3377N/A * @throws UnsupportedEncodingException if the charset is not supported 3377N/A // UnsupportedEncodingException should be thrown 0N/A * Constructs a new formatter. 0N/A * <p> The destination of the formatted output is a {@link StringBuilder} 0N/A * which may be retrieved by invoking {@link #out out()} and whose 0N/A * current content may be converted into a string by invoking {@link 0N/A * #toString toString()}. The locale used is the {@linkplain 0N/A * Locale#getDefault() default locale} for this instance of the Java 0N/A * Constructs a new formatter with the specified destination. 0N/A * <p> The locale used is the {@linkplain Locale#getDefault() default 0N/A * locale} for this instance of the Java virtual machine. 847N/A * Destination for the formatted output. If {@code a} is 847N/A * {@code null} then a {@link StringBuilder} will be created. 0N/A * Constructs a new formatter with the specified locale. 0N/A * <p> The destination of the formatted output is a {@link StringBuilder} 0N/A * which may be retrieved by invoking {@link #out out()} and whose current 0N/A * content may be converted into a string by invoking {@link #toString 0N/A * The {@linkplain java.util.Locale locale} to apply during 847N/A * formatting. If {@code l} is {@code null} then no localization 0N/A * Constructs a new formatter with the specified destination and locale. 847N/A * Destination for the formatted output. If {@code a} is 847N/A * {@code null} then a {@link StringBuilder} will be created. 0N/A * The {@linkplain java.util.Locale locale} to apply during 847N/A * formatting. If {@code l} is {@code null} then no localization 0N/A * Constructs a new formatter with the specified file name. 0N/A * <p> The charset used is the {@linkplain 0N/A * java.nio.charset.Charset#defaultCharset() default charset} for this 0N/A * instance of the Java virtual machine. 0N/A * <p> The locale used is the {@linkplain Locale#getDefault() default 0N/A * locale} for this instance of the Java virtual machine. 0N/A * The name of the file to use as the destination of this 0N/A * formatter. If the file exists then it will be truncated to 0N/A * zero size; otherwise, a new file will be created. The output 0N/A * will be written to the file and is buffered. 0N/A * @throws SecurityException 0N/A * If a security manager is present and {@link 0N/A * SecurityManager#checkWrite checkWrite(fileName)} denies write 0N/A * access to the file 0N/A * @throws FileNotFoundException 0N/A * If the given file name does not denote an existing, writable 0N/A * regular file and a new regular file of that name cannot be 0N/A * created, or if some other error occurs while opening or 0N/A * Constructs a new formatter with the specified file name and charset. 0N/A * <p> The locale used is the {@linkplain Locale#getDefault default 0N/A * locale} for this instance of the Java virtual machine. 0N/A * The name of the file to use as the destination of this 0N/A * formatter. If the file exists then it will be truncated to 0N/A * zero size; otherwise, a new file will be created. The output 0N/A * will be written to the file and is buffered. 0N/A * The name of a supported {@linkplain java.nio.charset.Charset 0N/A * @throws FileNotFoundException 0N/A * If the given file name does not denote an existing, writable 0N/A * regular file and a new regular file of that name cannot be 0N/A * created, or if some other error occurs while opening or 0N/A * @throws SecurityException 0N/A * If a security manager is present and {@link 0N/A * SecurityManager#checkWrite checkWrite(fileName)} denies write 0N/A * access to the file 0N/A * @throws UnsupportedEncodingException 0N/A * If the named charset is not supported 0N/A * Constructs a new formatter with the specified file name, charset, and 0N/A * The name of the file to use as the destination of this 0N/A * formatter. If the file exists then it will be truncated to 0N/A * zero size; otherwise, a new file will be created. The output 0N/A * will be written to the file and is buffered. 0N/A * The name of a supported {@linkplain java.nio.charset.Charset 0N/A * The {@linkplain java.util.Locale locale} to apply during 847N/A * formatting. If {@code l} is {@code null} then no localization 0N/A * @throws FileNotFoundException 0N/A * If the given file name does not denote an existing, writable 0N/A * regular file and a new regular file of that name cannot be 0N/A * created, or if some other error occurs while opening or 0N/A * @throws SecurityException 0N/A * If a security manager is present and {@link 0N/A * SecurityManager#checkWrite checkWrite(fileName)} denies write 0N/A * access to the file 0N/A * @throws UnsupportedEncodingException 0N/A * If the named charset is not supported 0N/A * Constructs a new formatter with the specified file. 0N/A * <p> The charset used is the {@linkplain 0N/A * java.nio.charset.Charset#defaultCharset() default charset} for this 0N/A * instance of the Java virtual machine. 0N/A * <p> The locale used is the {@linkplain Locale#getDefault() default 0N/A * locale} for this instance of the Java virtual machine. 0N/A * The file to use as the destination of this formatter. If the 0N/A * file exists then it will be truncated to zero size; otherwise, 0N/A * a new file will be created. The output will be written to the 0N/A * file and is buffered. 0N/A * @throws SecurityException 0N/A * If a security manager is present and {@link 0N/A * SecurityManager#checkWrite checkWrite(file.getPath())} denies 0N/A * write access to the file 0N/A * @throws FileNotFoundException 0N/A * If the given file object does not denote an existing, writable 0N/A * regular file and a new regular file of that name cannot be 0N/A * created, or if some other error occurs while opening or 0N/A * Constructs a new formatter with the specified file and charset. 0N/A * <p> The locale used is the {@linkplain Locale#getDefault default 0N/A * locale} for this instance of the Java virtual machine. 0N/A * The file to use as the destination of this formatter. If the 0N/A * file exists then it will be truncated to zero size; otherwise, 0N/A * a new file will be created. The output will be written to the 0N/A * file and is buffered. 0N/A * The name of a supported {@linkplain java.nio.charset.Charset 0N/A * @throws FileNotFoundException 0N/A * If the given file object does not denote an existing, writable 0N/A * regular file and a new regular file of that name cannot be 0N/A * created, or if some other error occurs while opening or 0N/A * @throws SecurityException 0N/A * If a security manager is present and {@link 0N/A * SecurityManager#checkWrite checkWrite(file.getPath())} denies 0N/A * write access to the file 0N/A * @throws UnsupportedEncodingException 0N/A * If the named charset is not supported 0N/A * Constructs a new formatter with the specified file, charset, and 0N/A * The file to use as the destination of this formatter. If the 0N/A * file exists then it will be truncated to zero size; otherwise, 0N/A * a new file will be created. The output will be written to the 0N/A * file and is buffered. 0N/A * The name of a supported {@linkplain java.nio.charset.Charset 0N/A * The {@linkplain java.util.Locale locale} to apply during 847N/A * formatting. If {@code l} is {@code null} then no localization 0N/A * @throws FileNotFoundException 0N/A * If the given file object does not denote an existing, writable 0N/A * regular file and a new regular file of that name cannot be 0N/A * created, or if some other error occurs while opening or 0N/A * @throws SecurityException 0N/A * If a security manager is present and {@link 0N/A * SecurityManager#checkWrite checkWrite(file.getPath())} denies 0N/A * write access to the file 0N/A * @throws UnsupportedEncodingException 0N/A * If the named charset is not supported 0N/A * Constructs a new formatter with the specified print stream. 0N/A * <p> The locale used is the {@linkplain Locale#getDefault() default 0N/A * locale} for this instance of the Java virtual machine. 0N/A * <p> Characters are written to the given {@link java.io.PrintStream 0N/A * PrintStream} object and are therefore encoded using that object's 0N/A * The stream to use as the destination of this formatter. 0N/A * Constructs a new formatter with the specified output stream. 0N/A * <p> The charset used is the {@linkplain 0N/A * java.nio.charset.Charset#defaultCharset() default charset} for this 0N/A * instance of the Java virtual machine. 0N/A * <p> The locale used is the {@linkplain Locale#getDefault() default 0N/A * locale} for this instance of the Java virtual machine. 0N/A * The output stream to use as the destination of this formatter. 0N/A * The output will be buffered. 0N/A * Constructs a new formatter with the specified output stream and 0N/A * <p> The locale used is the {@linkplain Locale#getDefault default 0N/A * locale} for this instance of the Java virtual machine. 0N/A * The output stream to use as the destination of this formatter. 0N/A * The output will be buffered. 0N/A * The name of a supported {@linkplain java.nio.charset.Charset 0N/A * @throws UnsupportedEncodingException 0N/A * If the named charset is not supported 0N/A * Constructs a new formatter with the specified output stream, charset, 0N/A * The output stream to use as the destination of this formatter. 0N/A * The output will be buffered. 0N/A * The name of a supported {@linkplain java.nio.charset.Charset 0N/A * The {@linkplain java.util.Locale locale} to apply during 847N/A * formatting. If {@code l} is {@code null} then no localization 0N/A * @throws UnsupportedEncodingException 0N/A * If the named charset is not supported 0N/A * Returns the locale set by the construction of this formatter. 0N/A * <p> The {@link #format(java.util.Locale,String,Object...) format} method 0N/A * for this object which has a locale argument does not change this value. 847N/A * @return {@code null} if no localization is applied, otherwise a 0N/A * @throws FormatterClosedException 0N/A * If this formatter has been closed by invoking its {@link 0N/A * Returns the destination for the output. 0N/A * @return The destination for the output 0N/A * @throws FormatterClosedException 0N/A * If this formatter has been closed by invoking its {@link 847N/A * Returns the result of invoking {@code toString()} on the destination 0N/A * for the output. For example, the following code formats text into a 0N/A * {@link StringBuilder} then retrieves the resultant string: 0N/A * Formatter f = new Formatter(); 0N/A * f.format("Last reboot at %tc", lastRebootDate); 0N/A * String s = f.toString(); 0N/A * // -> s == "Last reboot at Sat Jan 01 00:00:00 PST 2000" 0N/A * </pre></blockquote> 0N/A * <p> An invocation of this method behaves in exactly the same way as the 0N/A * out().toString() </pre> 847N/A * <p> Depending on the specification of {@code toString} for the {@link 0N/A * Appendable}, the returned string may or may not contain the characters 0N/A * written to the destination. For instance, buffers typically return 847N/A * their contents in {@code toString()}, but streams cannot since the 0N/A * data is discarded. 847N/A * @return The result of invoking {@code toString()} on the destination 0N/A * @throws FormatterClosedException 0N/A * If this formatter has been closed by invoking its {@link 0N/A * Flushes this formatter. If the destination implements the {@link 847N/A * java.io.Flushable} interface, its {@code flush} method will be invoked. 0N/A * <p> Flushing a formatter writes any buffered output in the destination 0N/A * to the underlying stream. 0N/A * @throws FormatterClosedException 0N/A * If this formatter has been closed by invoking its {@link 0N/A * Closes this formatter. If the destination implements the {@link 847N/A * java.io.Closeable} interface, its {@code close} method will be invoked. 0N/A * <p> Closing a formatter allows it to release resources it may be holding 0N/A * (such as open files). If the formatter is already closed, then invoking 0N/A * this method has no effect. 0N/A * <p> Attempting to invoke any methods except {@link #ioException()} in 0N/A * this formatter after it has been closed will result in a {@link 0N/A * FormatterClosedException}. 847N/A * Returns the {@code IOException} last thrown by this formatter's {@link 847N/A * <p> If the destination's {@code append()} method never throws 847N/A * {@code IOException}, then this method will always return {@code null}. 847N/A * @return The last exception thrown by the Appendable or {@code null} if 0N/A * no such exception exists. 0N/A * Writes a formatted string to this object's destination using the 0N/A * specified format string and arguments. The locale used is the one 0N/A * defined during the construction of this formatter. 0N/A * A format string as described in <a href="#syntax">Format string 0N/A * Arguments referenced by the format specifiers in the format 0N/A * string. If there are more arguments than format specifiers, the 0N/A * extra arguments are ignored. The maximum number of arguments is 0N/A * limited by the maximum dimension of a Java array as defined by 4008N/A * <cite>The Java™ Virtual Machine Specification</cite>. 0N/A * @throws IllegalFormatException 0N/A * If a format string contains an illegal syntax, a format 0N/A * specifier that is incompatible with the given arguments, 0N/A * insufficient arguments given the format string, or other 0N/A * illegal conditions. For specification of all possible 0N/A * formatting errors, see the <a href="#detail">Details</a> 0N/A * section of the formatter class specification. 0N/A * @throws FormatterClosedException 0N/A * If this formatter has been closed by invoking its {@link 0N/A * @return This formatter 0N/A * Writes a formatted string to this object's destination using the 0N/A * specified locale, format string, and arguments. 0N/A * The {@linkplain java.util.Locale locale} to apply during 847N/A * formatting. If {@code l} is {@code null} then no localization 0N/A * is applied. This does not change this object's locale that was 0N/A * set during construction. 0N/A * A format string as described in <a href="#syntax">Format string 0N/A * Arguments referenced by the format specifiers in the format 0N/A * string. If there are more arguments than format specifiers, the 0N/A * extra arguments are ignored. The maximum number of arguments is 0N/A * limited by the maximum dimension of a Java array as defined by 4008N/A * <cite>The Java™ Virtual Machine Specification</cite>. 0N/A * @throws IllegalFormatException 0N/A * If a format string contains an illegal syntax, a format 0N/A * specifier that is incompatible with the given arguments, 0N/A * insufficient arguments given the format string, or other 0N/A * illegal conditions. For specification of all possible 0N/A * formatting errors, see the <a href="#detail">Details</a> 0N/A * section of the formatter class specification. 0N/A * @throws FormatterClosedException 0N/A * If this formatter has been closed by invoking its {@link 0N/A * @return This formatter 0N/A // index of last argument referenced 0N/A // last ordinary index 0N/A case -
2:
// fixed string, "%n", or "%%" 0N/A case -
1:
// relative index 0N/A case 0:
// ordinary index 0N/A default:
// explicit index 0N/A // %[argument_index$][flags][width][.precision][t]conversion 0N/A =
"%(\\d+\\$)?([-#+ 0,(\\<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])";
1819N/A * Finds format specifiers in the format string. 0N/A // Anything between the start of the string and the beginning 0N/A // of the format specifier is either fixed text or contains 0N/A // an invalid format string. 0N/A // Make sure we didn't miss any invalid format specifiers 0N/A // Assume previous characters were fixed text 0N/A // No more valid format specifiers. Check for possible invalid 0N/A // format specifiers. 0N/A // The rest of the string is fixed text 1819N/A // Any '%' found in the region starts an invalid format specifier. 0N/A private boolean dt =
false;
0N/A // Instead of Calendar.setLenient(true), perhaps we should 0N/A // wrap the IllegalArgumentException that might be thrown? 0N/A // Note that the following method uses an instance of the 0N/A // default time zone (TimeZone.getDefaultRef(). 0N/A // Note that the following method uses an instance of the 0N/A // default time zone (TimeZone.getDefaultRef(). 0N/A // Use the provided locale so that invocations of 0N/A // localizedMagnitude() use optimizations for null. 0N/A // Flags.UPPERCASE is set internally for legal conversions. 0N/A // '-' requires a width 0N/A // '-' requires a width 0N/A // '-' requires a width 0N/A // '-' and '0' require a width 0N/A // '-' requires a width 0N/A // leading sign indicator 0N/A // trailing sign indicator 0N/A // apply ALTERNATE (radix indicator for octal) before ZERO_PAD 0N/A // apply ALTERNATE (radix indicator for hex) before ZERO_PAD 0N/A // justify based on width 0N/A // leading sign indicator 0N/A // apply ALTERNATE (radix indicator for octal) before ZERO_PAD 0N/A // apply ALTERNATE (radix indicator for hex) before ZERO_PAD 0N/A // trailing sign indicator 0N/A // justify based on width 0N/A // leading sign indicator 0N/A ?
"INFINITY" :
"Infinity");
0N/A // trailing sign indicator 0N/A // justify based on width 0N/A // !Double.isInfinite(value) && !Double.isNaN(value) 0N/A // Create a new FormattedFloatingDecimal with the desired 0N/A // If the precision is zero and the '#' flag is set, add the 0N/A // requested decimal point. 0N/A // Create a new FormattedFloatingDecimal with the desired 0N/A // MAX_FD_CHARS + 1 (round?) 0N/A // If the precision is zero and the '#' flag is set, add the 0N/A // requested decimal point. 0N/A // MAX_FD_CHARS + 1 (round?) 0N/A // If the precision is zero and the '#' flag is set, add the 0N/A // requested decimal point. 0N/A // assume that we want all of the digits 0N/A // don't localize hex 0N/A for (i =
len -
1; i >=
0; i--) {
0N/A // Add zeros to the requested precision. 0N/A // Look for the dot. If we don't find one, the we'll need to add 0N/A // it before we add the zeros. 0N/A // Determine existing precision. 0N/A // Create new array with existing contents. 0N/A // Add dot if previously determined to be necessary. 0N/A // Method assumes that d > 0. 0N/A // Let Double.toHexString handle simple cases 0N/A // If this is subnormal input so normalize (could be faster to 0N/A // do as integer operation). 0N/A // Calculate the exponent. This is not just exponent + 54 0N/A // since the former is not the normalized exponent. 0N/A // Deterime the number of bits to keep. 0N/A // Bits to round away. 0N/A // To decide how to round, look at the low-order bit of the 0N/A // working significand, the highest order discarded bit (the 0N/A // round bit) and whether any of the lower order discarded bits 0N/A // are nonzero (the sticky bit). 0N/A // Infinite result generated by rounding 0N/A // Create a normalized subnormal string. 0N/A // No 'p' character in hex string. 0N/A // Get exponent and append at the end. 0N/A // leading sign indicator 0N/A // trailing sign indicator 0N/A // justify based on width 0N/A // Create a new BigDecimal with the desired precision. 0N/A // Add a decimal point if necessary. The mantissa may not 0N/A // contain a decimal point if the scale is zero (the internal 0N/A // representation has no fractional part) or the original 0N/A // precision is one. Append a decimal point if '#' is set or if 0N/A // we require zero padding to get to the requested precision. 0N/A // Add trailing zeros in the case precision is greater than 0N/A // the number of available digits after the decimal separator. 0N/A // Create a new BigDecimal with the desired precision. 3770N/A // more "scale" digits than the requested "precision" 0N/A // Add a decimal point if necessary. The mantissa may not 0N/A // contain a decimal point if the scale is zero (the internal 0N/A // representation has no fractional part). Append a decimal 0N/A // point if '#' is set or we require zero padding to get to the 0N/A // requested precision. 0N/A // Add trailing zeros if the precision is greater than the 0N/A // number of available digits after the decimal separator. 0N/A // g precision (# sig digits) = #x + #y 0N/A // exponent = #x - 1 0N/A // => f precision = g precision - exponent - 1 0N/A // g precision (# sig digits) = #z 0N/A // f precision = #0 (after '.') + #z 0N/A // exponent = - #0 (after '.') - 1 0N/A // => f precision = g precision - exponent - 1 0N/A // This conversion isn't supported. The error should be 0N/A // reported earlier. 0N/A // char[] with canonical string representation 0N/A // The exponent will be formatted as a sign ('+' or '-') followed 0N/A // by the exponent zero-padded to include at least two digits. 0N/A // Construct a buffer, with sufficient capacity for all cases. 0N/A // If E-notation is needed, length will be: +1 if negative, +1 0N/A // if '.' needed, +2 for "E+", + up to 10 for adjusted 0N/A // exponent. Otherwise it could have +1 if negative, plus 0N/A // leading "0.00000" 0N/A // count of padding zeros 0N/A // Add a '.' to th mantissa if required 0N/A // Add trailing zeros in the case precision is greater than the number 0N/A // of available digits after the decimal separator. 0N/A // justify based on width 0N/A i = (i ==
0 || i ==
12 ?
12 : i %
12);
0N/A // Calendar.AM = 0, Calendar.PM = 1, LocaleElements defines upper 0N/A // combine minute and hour into a single integer 0N/A // this may be in wrong place for some locales 0N/A // -- Methods to support throwing exceptions -- 0N/A // determine localized grouping separator and size 0N/A for (
int j =
0; j <
len; j++) {
0N/A // localize the digits inserting group separators as necessary 0N/A for (
int j =
0; j <
len; j++) {
0N/A // no more group separators after the decimal separator 0N/A // apply zero padding 0N/A // parse those flags which may be provided by users 847N/A // Returns a string representation of the current {@code Flags}. 0N/A // Byte, Short, Integer, Long, BigInteger 0N/A // (and associated primitives due to autoboxing) 0N/A // Float, Double, BigDecimal 0N/A // (and associated primitives due to autoboxing) 0N/A // Character, Byte, Short, Integer 0N/A // (and associated primitives due to autoboxing) 0N/A // java.util.Date, java.util.Calendar, long 0N/A // if (arg.TYPE != boolean) return boolean 0N/A // if (arg != null) return true; else return false; 0N/A // if (arg instanceof Formattable) arg.formatTo() 0N/A // else arg.toString(); 0N/A // Returns true iff the Conversion is applicable to all objects. 0N/A // Returns true iff the Conversion is applicable to character. 0N/A // Returns true iff the Conversion is an integer type. 0N/A // Returns true iff the Conversion is a floating-point type. 0N/A // Returns true iff the Conversion does not require an argument 0N/A static final char HOUR =
'l';
// (1 - 12) -- like I 0N/A static final char AM_PM =
'p';
// (am or pm) 0N/A static final char SECOND =
'S';
// (00 - 60 - leap second) 0N/A static final char TIME =
'T';
// (24 hour hh:mm:ss) 0N/A static final char ZONE =
'Z';
// (symbol) 0N/A// * static final char ISO_WEEK_OF_YEAR_2 = 'g'; // cross %y %V 0N/A// * static final char ISO_WEEK_OF_YEAR_4 = 'G'; // cross %Y %V 0N/A static final char MONTH =
'm';
// (01 - 12) 0N/A// * static final char DAY_OF_WEEK_1 = 'u'; // (1 - 7) Monday 0N/A// * static final char WEEK_OF_YEAR_SUNDAY = 'U'; // (0 - 53) Sunday+ 0N/A// * static final char WEEK_OF_YEAR_MONDAY_01 = 'V'; // (01 - 53) Monday+ 0N/A// * static final char DAY_OF_WEEK_0 = 'w'; // (0 - 6) Sunday 0N/A// * static final char WEEK_OF_YEAR_MONDAY = 'W'; // (00 - 53) Monday 0N/A static final char YEAR_4 =
'Y';
// (0000 - 9999) 0N/A// * static final char LOCALE_TIME = 'X'; // (%H:%M:%S) - parse format? 0N/A // (Sat Nov 04 12:02:33 EST 1999) 0N/A// * static final char LOCALE_DATE = 'x'; // (mm/dd/yy) 0N/A// * case ISO_WEEK_OF_YEAR_2: 0N/A// * case ISO_WEEK_OF_YEAR_4: 0N/A// * case DAY_OF_WEEK_1: 0N/A// * case WEEK_OF_YEAR_SUNDAY: 0N/A// * case WEEK_OF_YEAR_MONDAY_01: 0N/A// * case DAY_OF_WEEK_0: 0N/A// * case WEEK_OF_YEAR_MONDAY: 0N/A// * case LOCALE_TIME: 0N/A// * case LOCALE_DATE: