- 浏览: 11805920 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
笨蛋咯:
获取不到信息?
C#枚举硬件设备 -
guokaiwhu:
能把plan的数据结构图画出来,博主的耐心和细致令人佩服。
PostgreSQL服务过程中的那些事二:Pg服务进程处理简单查询五:规划成plantree -
gao807877817:
学习
BitmapFactory.Options详解 -
GB654:
楼主,我想问一下,如何在创建PPT时插入备注信息,虽然可以解析 ...
java转换ppt,ppt转成图片,获取备注,获取文本 -
jpsb:
多谢 ,不过我照搬你的sql查不到,去掉utl_raw.cas ...
关于oracle中clob字段查询的问题
Formatter
|
Java™ Platform Standard Ed. 6 |
||||||||
PREV CLASSNEXT CLASS | FRAMESNO FRAMESAll Classes | ||||||||
SUMMARY:NESTED| FIELD |CONSTR|METHOD | DETAIL: FIELD |CONSTR|METHOD |
java.util
Class Formatter
java.lang.Objectjava.util.Formatter
public final classFormatter
Aninterpreter(解释器) for printf-style format strings. This class provides support forlayout(布局)justification(对齐) andalignment(排列),common(一般的)formats(格式)
for numeric(数字), string, and date/time data, and locale-specific(特定的环境) output. Common Java types such asbyte,BigDecimal
,
andCalendar
are supported. Limited formatting customization(定制) for arbitrary(任意) user types is provided through
theFormattable
interface.
Formatters are not necessarily safe for multithreaded access. Thread safety is optional and is theresponsibility(负责) of users of methods in this class.
Formatted printing for the Java language is heavilyinspired(启发的) by C'sprintf.Although(虽然) the format strings aresimilar(类似于) to C, somecustomizations(定制) have been made toaccommodate(适应) the Java language andexploit(开发) some of itsfeatures(特征). Also, Java formatting is morestrict(严格) than C's; for example, if a conversion isincompatible(不兼容) with aflag(标志), an exception will be thrown. In Cinapplicable(不适用的) flags aresilently(默默的)ignored(忽视). The format strings are thusintended(因此预期)to berecognizable(可辨别的) to Cprogrammers(程序员) but not necessarilycompletely(完全)compatible(兼容的) with those in C.
Examples ofexpected(期望) usage:
StringBuilder sb = new StringBuilder(); // Send all output to the Appendable object sb Formatter formatter = new Formatter(sb, Locale.US); // Explicit argument indices may be used to re-order output. formatter.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d") // -> " d c b a" // Optional locale as the first argument can be used to get // locale-specific formatting of numbers. The precision and width can be // given to round and align the value. formatter.format(Locale.FRANCE, "e = %+10.4f", Math.E); // -> "e = +2,7183" // The '(' numeric flag may be used to format negative numbers with // parentheses rather than a minus sign. Group separators are // automatically inserted. formatter.format("Amount gained or lost since last statement: $ %(,.2f", balanceDelta); // -> "Amount gained or lost since last statement: $ (6,217.58)"
Convenience methods for common formatting requests exist as illustrated by the following invocations:
// Writes a formatted string to System.out. System.out.format("Local time: %tT", Calendar.getInstance()); // -> "Local time: 13:34:18" // Writes formatted output to System.err. System.err.printf("Unable to open file '%1$s': %2$s", fileName, exception.getMessage()); // -> "Unable to open file 'food': No such file or directory"
Like C'ssprintf(3), Strings may be formatted using the static methodString.format
:
// Format a string containing a date. import java.util.Calendar; import java.util.GregorianCalendar; import static java.util.Calendar.*; Calendar c = new GregorianCalendar(1995, MAY, 23); String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c); // -> s == "Duke's Birthday: May 23, 1995"
Organization(结构)
Thisspecification(规范)isdivided(分为) intotwo sections(两个部分). The first section,Summary,covers(涵盖) thebasic formatting(基本格式)concepts(概念). This section isintended(准备) for users who want to getstarted quickly(快速入门) and arefamiliar(熟悉) with formatted printing in other programming languages. The second section,Details(详细信息), covers thespecific(具体的)implementation details(实现细节). It is intended for users who want more precise(精确的)specification(规范) of formattingbehavior(行为).
Summary(摘要)
This section is intended to provide abrief(简短的) overview(概述) of formatting concepts. For precisebehavioral(行为) details, refer(参阅) to theDetailssection.
Format String Syntax
Every method which produces formatted outputrequires(需要) aformat stringand anargument list. The format string is aString
which
may contain fixed(固定的) text and one or moreembedded(嵌入)formatspecifiers(说明符). Consider(考虑) the following example:
This format string is the first argument to theformatmethod. It contains three format specifiers "%1$tm", "%1$te", and "%1$tY" whichindicate(表明) how the arguments should be processed(处理) and where they should be inserted(嵌入) in the text. Theremaining(剩下的) portions of the format string are fixed text including"Dukes Birthday: "and any other spaces orpunctuation(标点符号). The argument list consists of all arguments passed to the method after the format string. In the above(以上的) example, the argument list is of size one and consists of theCalendar c = ...; String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c);
Calendar
objectc.
- The format specifiers for general, character, and numeric types have the following syntax:
%[argument_index$][flags][width][.precision]conversion
The optionalargument_indexis a decimal integerindicating(表明) the position of the argument in the argument list. The first argument is referenced by "1$", the second by "2$", etc.
The optionalflagsis a set of characters that modify the output format. The set ofvalid(有效性)flagsdepends(取决于) on theconversion(转换类型).
The optionalwidthis anon-negative(非负十进制整数) decimal integerindicating(代表) the minimum number of characters to be written to the output.
The optionalprecisionis a non-negative decimal integer usually used to restrict(限制) the number of characters. The specific behaviordepends on(取决于) the conversion.
The requiredconversionis a character indicating how the argument should be formatted. The set of valid conversions for a given argument depends on the argument's data type.
- The format specifiers for types which are used to represents(代表) dates and times have the following syntax:
%[argument_index$][flags][width]conversion
The optionalargument_index,flagsandwidthare defined as above.
The requiredconversionis a two character sequence. The first character is't'or'T'. The second characterindicates(表明) the format to be used. These characters are similar(类似于) to but notcompletely(完全)identical(等同于) to those defined by GNUdateand POSIXstrftime(3c).
- The formatspecifiers(说明符) which do notcorrespond(对应) to arguments have the following syntax:
%[flags][width]conversion
The optionalflagsandwidthis defined as above.
The requiredconversionis a character indicating content to be inserted in the output.
Conversions
Conversions are divided into the following categories:
- General- may be applied to any argument type
-
Character- may be applied to basic types which represent Unicode characters:char,
Character
,byte,Byte
,short, andShort
. This conversion may also be applied to the typesintandInteger
whenCharacter.isValidCodePoint(int)
returnstrue -
Numeric
-
Integral- may be applied to Java integral types:byte,
Byte
,short,Short
,intandInteger
,long,Long
, andBigInteger
-
Floating Point- may be applied to Java floating-point types:float,
Float
,double,Double
, andBigDecimal
-
Integral- may be applied to Java integral types:byte,
-
Date/Time- may be applied to Java types which are capable of encoding a date or time:long,
Long
,Calendar
, andDate
. - Percent- produces a literal'%'('\u0025')
- Line Separator- produces the platform-specific line separator
The following table summarizes the supported conversions. Conversions denoted by an upper-case character (i.e.'B','H','S','C','X','E','G','A', and'T') are the same as
those for the corresponding lower-case conversion characters except that the result is converted to upper case according to the rules of the prevailingLocale
.
The result is equivalent to the following invocation ofString.toUpperCase()
out.toUpperCase()
'b','B' | general | If the argumentargisnull, then the result is "false". Ifargis abooleanorBoolean ,
then the result is the string returned byString.valueOf() . Otherwise, the result is "true". |
'h','H' | general | If the argumentargisnull, then the result is "null". Otherwise, the result is obtained by invokingInteger.toHexString(arg.hashCode()). |
's','S' | general | If the argumentargisnull, then the result is "null". IfargimplementsFormattable ,
thenarg.formatTo is invoked. Otherwise, the result is obtained by invokingarg.toString(). |
'c','C' | character | The result is a Unicode character |
'd' | integral | The result is formatted as a decimal integer |
'o' | integral | The result is formatted as an octal integer |
'x','X' | integral | The result is formatted as a hexadecimal integer |
'e','E' | floating point | The result is formatted as a decimal number in computerized scientific notation |
'f' | floating point | The result is formatted as a decimal number |
'g','G' | floating point | The result is formatted using computerized scientific notation or decimal format, depending on the precision and the value after rounding. |
'a','A' | floating point | The result is formatted as a hexadecimal floating-point number with a significand and an exponent |
't','T' | date/time | Prefix for date and time conversion characters. SeeDate/Time Conversions. |
'%' | percent | The result is a literal'%'('\u0025') |
'n' | line separator | The result is the platform-specific line separator |
Any characters not explicitly defined as conversions are illegal and are reserved for future extensions.
Date/Time Conversions
The following date and time conversion suffix characters are defined for the't'and'T'conversions. The types are similar to but not completely identical to those defined by GNUdateand POSIXstrftime(3c). Additional conversion types are provided to access Java-specific functionality (e.g.'L'for milliseconds within the second).
The following conversion characters are used for formatting times:
'H' | Hour of the day for the 24-hour clock, formatted as two digits with a leading zero as necessary i.e.00 - 23. |
'I' | Hour for the 12-hour clock, formatted as two digits with a leading zero as necessary, i.e.01 - 12. |
'k' | Hour of the day for the 24-hour clock, i.e.0 - 23. |
'l' | Hour for the 12-hour clock, i.e.1 - 12. |
'M' | Minute within the hour formatted as two digits with a leading zero as necessary, i.e.00 - 59. |
'S' | Seconds within the minute, formatted as two digits with a leading zero as necessary, i.e.00 - 60("60" is a special value required to support leap seconds). |
'L' | Millisecond within the second formatted as three digits with leading zeros as necessary, i.e.000 - 999. |
'N' | Nanosecond within the second, formatted as nine digits with leading zeros as necessary, i.e.000000000 - 999999999. |
'p' | Locale-specificmorning or afternoonmarker in lower case, e.g."am" or "pm". Use of the conversion prefix'T'forces this output to upper case. |
'z' | RFC 822style numeric time zone offset from GMT, e.g.-0800. |
'Z' | A string representing the abbreviation for the time zone. The Formatter's locale will supersede the locale of the argument (if any). |
's' | Seconds since the beginning of the epoch starting at 1 January 197000:00:00UTC, i.e.Long.MIN_VALUE/1000toLong.MAX_VALUE/1000. |
'Q' | Milliseconds since the beginning of the epoch starting at 1 January 197000:00:00UTC, i.e.Long.MIN_VALUEtoLong.MAX_VALUE. |
The following conversion characters are used for formatting dates:
'B' | Locale-specificfull month name, e.g."January","February". |
'b' | Locale-specificabbreviated month name, e.g."Jan","Feb". |
'h' | Same as'b'. |
'A' | Locale-specific full name of theday of the week, e.g."Sunday","Monday" |
'a' | Locale-specific short name of theday of the week, e.g."Sun","Mon" |
'C' | Four-digit year divided by100, formatted as two digits with leading zero as necessary, i.e.00 - 99 |
'Y' | Year, formatted as at least four digits with leading zeros as necessary, e.g.0092equals92CE for the Gregorian calendar. |
'y' | Last two digits of the year, formatted with leading zeros as necessary, i.e.00 - 99. |
'j' | Day of year, formatted as three digits with leading zeros as necessary, e.g.001 - 366for the Gregorian calendar. |
'm' | Month, formatted as two digits with leading zeros as necessary, i.e.01 - 13. |
'd' | Day of month, formatted as two digits with leading zeros as necessary, i.e.01 - 31 |
'e' | Day of month, formatted as two digits, i.e.1 - 31. |
The following conversion characters are used for formatting common date/time compositions.
'R' | Time formatted for the 24-hour clock as"%tH:%tM" |
'T' | Time formatted for the 24-hour clock as"%tH:%tM:%tS". |
'r' | Time formatted for the 12-hour clock as"%tI:%tM:%tS %Tp". The location of the morning or afternoon marker ('%Tp') may be locale-dependent. |
'D' | Date formatted as"%tm/%td/%ty". |
'F' | ISO 8601complete date formatted as"%tY-%tm-%td". |
'c' | Date and time formatted as"%ta %tb %td %tT %tZ %tY", e.g."Sun Jul 20 16:17:00 EDT 1969". |
Any characters not explicitly defined as date/time conversion suffixes are illegal and are reserved for future extensions.
Flags
The following table summarizes the supported flags.ymeans the flag is supported for the indicated argument types.
'-' | y | y | y | y | y | The result will be left-justified. |
'#' | y1 | - | y3 | y | - | The result should use a conversion-dependent alternate form |
'+' | - | - | y4 | y | - | The result will always include a sign |
' ' | - | - | y4 | y | - | The result will include a leading space for positive values |
'0' | - | - | y | y | - | The result will be zero-padded |
',' | - | - | y2 | y5 | - | The result will include locale-specificgrouping separators |
'(' | - | - | y4 | y5 | - | The result will enclose negative numbers in parentheses |
1Depends on the definition ofFormattable
.
2For'd'conversion only.
3For'o','x', and'X'conversions only.
4For'd','o','x', and'X'conversions applied toBigInteger
or'd'applied
tobyte,Byte
,short,Short
,intandInteger
,long,
andLong
.
5For'e','E','f','g', and'G'conversions only.
Any characters not explicitly defined as flags are illegal and are reserved for future extensions.
Width
The width is the minimum number of characters to be written to the output. For the line separator conversion, width is not applicable; if it is provided, an exception will be thrown.
Precision
For general argument types, the precision is the maximum number of characters to be written to the output.
For the floating-point conversions'e','E', and'f'the precision is the number of digits after the decimal separator. If the conversion is'g'or'G', then the precision is the total number of digits in the resulting magnitude after rounding. If the conversion is'a'or'A', then the precision must not be specified.
For character, integral, and date/time argument types and the percent and line separator conversions, the precision is not applicable; if a precision is provided, an exception will be thrown.
Argument Index
The argument index is a decimal integer indicating the position of the argument in the argument list. The first argument is referenced by "1$", the second by "2$", etc.
Another way to reference arguments by position is to use the'<'('\u003c') flag, which causes the argument for the previous format specifier to be re-used. For example, the following two statements would produce identical strings:
Calendar c = ...; String s1 = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c); String s2 = String.format("Duke's Birthday: %1$tm %<te,%<tY", c);
Details
This section is intended to provide behavioral details for formatting, including conditions and exceptions, supported data types, localization, and interactions between flags, conversions, and data types. For an overview of formatting concepts, refer to theSummary
Any characters not explicitly defined as conversions, date/time conversion suffixes, or flags are illegal and are reserved for future extensions. Use of such a character in a format string will cause anUnknownFormatConversionException
orUnknownFormatFlagsException
to
be thrown.
If the format specifier contains a width or precision with an invalid value or which is otherwise unsupported, then aIllegalFormatWidthException
orIllegalFormatPrecisionException
respectively
will be thrown.
If a format specifier contains a conversion character that is not applicable to the corresponding argument, then anIllegalFormatConversionException
will
be thrown.
All specified exceptions may be thrown by any of theformatmethods ofFormatteras well as by anyformatconvenience methods such asString.format
andPrintStream.printf
.
Conversions denoted by an upper-case character (i.e.'B','H','S','C','X','E','G','A', and'T') are the same as those for the corresponding lower-case conversion characters
except that the result is converted to upper case according to the rules of the prevailingLocale
. The result is equivalent
to the following invocation ofString.toUpperCase()
out.toUpperCase()
General
The following general conversions may be applied to any argument type:
'b' | '\u0062' | Produces either "true" or "false" as returned byBoolean.toString(boolean) .
If the argument isnull, then the result is "false". If the argument is abooleanor If the'#'flag is given, then a |
'B' | '\u0042' | The upper-case variant of'b'. |
'h' | '\u0068' | Produces a string representing the hash code value of the object.
If the argument,argisnull, then the result is "null". Otherwise, the result is obtained by invokingInteger.toHexString(arg.hashCode()). If the'#'flag is given, then a |
'H' | '\u0048' | The upper-case variant of'h'. |
's' | '\u0073' | Produces a string.
If the argument isnull, then the result is "null". If the argument implements If the'#'flag is given and the argument is not a |
'S' | '\u0053' | The upper-case variant of's'. |
The followingflagsapply to general conversions:
'-' | '\u002d' | Left justifies the output. Spaces ('\u0020') will be added at the end of the converted value as required to fill the minimum width of the field. If the width is not provided,
then aMissingFormatWidthException will be thrown. If this flag is not given then the output will be right-justified. |
'#' | '\u0023' | Requires the output use an alternate form. The definition of the form is specified by the conversion. |
Thewidthis the minimum number of characters to be written to the output. If the length of the converted value is less than the width then the output will be padded by' '(\u0020') until the total number of characters equals the width. The padding is on the left by default. If the'-'flag is given, then the padding will be on the right. If the width is not specified then there is no minimum.
The precision is the maximum number of characters to be written to the output. The precision is applied before the width, thus the output will be truncated toprecisioncharacters even if the width is greater than the precision. If the precision is not specified then there is no explicit limit on the number of characters.
Character
This conversion may be applied tocharandCharacter
.
It may also be applied to the typesbyte,Byte
,short,
andShort
,intandInteger
whenCharacter.isValidCodePoint(int)
returnstrue.
If it returnsfalsethen anIllegalFormatCodePointException
will
be thrown.
'c' | '\u0063' | Formats the argument as a Unicode character as described inUnicode Character Representation.
This may be more than one 16-bitcharin the case where the argument represents a supplementary character.
If the'#'flag is given, then a |
'C' | '\u0043' | The upper-case variant of'c'. |
The'-'flag defined forGeneral conversionsapplies. If the'#'flag is given, then aFormatFlagsConversionMismatchException
will
be thrown.
The width is defined as forGeneral conversions.
The precision is not applicable. If the precision is specified then anIllegalFormatPrecisionException
will be thrown.
Numeric
Numeric conversions are divided into the following categories:
Numeric types will be formatted according to the following algorithm:
After digits are obtained for the integer part, fractional part, and exponent (as appropriate for the data type), the following transformation is applied:
- Each digit characterdin the string is replaced by a locale-specific digit computed relative to the current locale'szero digitz; that isd -'0'+ z.
- If a decimal separator is present, a locale-specificdecimal separatoris substituted.
- If the','('\u002c')flagis given, then the locale-specificgrouping separatoris inserted by scanning the integer part of the string from least significant to most significant digits and inserting a separator at intervals defined by the locale'sgrouping size.
- If the'0'flag is given, then the locale-specificzero digitsare inserted after the sign character, if any, and before the first non-zero digit, until the length of the string is equal to the requested field width.
- If the value is negative and the'('flag is given, then a'('('\u0028') is prepended and a')'('\u0029') is appended.
- If the value is negative (or floating-point negative zero) and'('flag is not given, then a'-'('\u002d') is prepended.
- If the'+'flag is given and the value is positive or zero (or floating-point positive zero), then a'+'('\u002b') will be prepended.
If the value is NaN or positive infinity the literal strings "NaN" or "Infinity" respectively, will be output. If the value is negative infinity, then the output will be "(Infinity)" if the'('flag is given otherwise the output will be "-Infinity". These values are not localized.
Byte, Short, Integer, and Long
The following conversions may be applied tobyte,Byte
,short,Short
,intandInteger
,long,
andLong
.
'd' | '\u0054' | Formats the argument as a decimal integer. Thelocalization algorithmis applied.
If the'0'flag is given and the value is negative, then the zero padding will occur after the sign. If the'#'flag is given then a |
'o' | '\u006f' | Formats the argument as an integer in base eight. No localization is applied.
Ifxis negative then the result will be an unsigned value generated by adding 2nto the value wherenis the number of bits in the type as returned by the staticSIZEfield in theByte,Short,Integer, orLongclasses as appropriate. If the'#'flag is given then the output will always begin with the radix indicator'0'. If the'0'flag is given then the output will be padded with leading zeros to the field width following any indication of sign. If'(','+', ' ', or','flags are given then a |
'x' | '\u0078' | Formats the argument as an integer in base sixteen. No localization is applied.
Ifxis negative then the result will be an unsigned value generated by adding 2nto the value wherenis the number of bits in the type as returned by the staticSIZEfield in theByte,Short,Integer, orLongclasses as appropriate. If the'#'flag is given then the output will always begin with the radix indicator"0x". If the'0'flag is given then the output will be padded to the field width with leading zeros after the radix indicator or sign (if present). If'(',' ','+', or','flags are given then a |
'X' | '\u0058' | The upper-case variant of'x'. The entire string representing the number will be converted toupper caseincluding the'x'(if any) and all hexadecimal digits'a'-'f'('\u0061'-'\u0066'). |
If the conversion is'o','x', or'X'and both the'#'and the'0'flags are given, then result will contain the radix indicator ('0'for octal and"0x"or"0X"for hexadecimal), some number of zeros (based on the width), and the value.
If the'-'flag is not given, then the space padding will occur before the sign.
The followingflagsapply to numeric integral conversions:
'+' | '\u002b' | Requires the output to include a positive sign for all positive numbers. If this flag is not given then only negative values will include a sign.
If both the'+'and' 'flags are given then an |
' ' | '\u0020' | Requires the output to include a single extra space ('\u0020') for non-negative values.
If both the'+'and' 'flags are given then an |
'0' | '\u0030' | Requires the output to be padded with leadingzerosto the minimum field width
following any sign or radix indicator except when converting NaN or infinity. If the width is not provided, then aMissingFormatWidthException will
be thrown.
If both the'-'and'0'flags are given then an |
',' | '\u002c' | Requires the output to include the locale-specificgroup separatorsas described in the"group" sectionof the localization algorithm. |
'(' | '\u0028' | Requires the output to prepend a'('('\u0028') and append a')'('\u0029') to negative values. |
If noflagsare given the default formatting is as follows:
- The output is right-justified within thewidth
- Negative numbers begin with a'-'('\u002d')
- Positive numbers and zero do not include a sign or extra leading space
- No grouping separators are included
Thewidthis the minimum number of characters to be written to the output. This includes any signs, digits, grouping separators, radix indicator, and parentheses. If the length of the converted value is less than the width then the output will be padded by spaces ('\u0020') until the total number of characters equals width. The padding is on the left by default. If'-'flag is given then the padding will be on the right. If width is not specified then there is no minimum.
The precision is not applicable. If precision is specified then anIllegalFormatPrecisionException
will be thrown.
The following conversions may be applied toBigInteger
.
'd' | '\u0054' | Requires the output to be formatted as a decimal integer. Thelocalization algorithmis
applied.
If the'#'flag is given |
'o' | '\u006f' | Requires the output to be formatted as an integer in base eight. No localization is applied.
Ifxis negative then the result will be a signed value beginning with'-'('\u002d'). Signed output is allowed for this type because unlike the primitive types it is not possible to create an unsigned equivalent without assuming an explicit data-type size. Ifxis positive or zero and the'+'flag is given then the result will begin with'+'('\u002b'). If the'#'flag is given then the output will always begin with'0'prefix. If the'0'flag is given then the output will be padded with leading zeros to the field width following any indication of sign. If the','flag is given then a |
'x' | '\u0078' | Requires the output to be formatted as an integer in base sixteen. No localization is applied.
Ifxis negative then the result will be a signed value beginning with'-'('\u002d'). Signed output is allowed for this type because unlike the primitive types it is not possible to create an unsigned equivalent without assuming an explicit data-type size. Ifxis positive or zero and the'+'flag is given then the result will begin with'+'('\u002b'). If the'#'flag is given then the output will always begin with the radix indicator"0x". If the'0'flag is given then the output will be padded to the field width with leading zeros after the radix indicator or sign (if present). If the','flag is given then a |
'X' | '\u0058' | The upper-case variant of'x'. The entire string representing the number will be converted toupper caseincluding the'x'(if any) and all hexadecimal digits'a'-'f'('\u0061'-'\u0066'). |
If the conversion is'o','x', or'X'and both the'#'and the'0'flags are given, then result will contain the base indicator ('0'for octal and"0x"or"0X"for hexadecimal), some number of zeros (based on the width), and the value.
If the'0'flag is given and the value is negative, then the zero padding will occur after the sign.
If the'-'flag is not given, then the space padding will occur before the sign.
Allflagsdefined for Byte, Short, Integer, and Long apply. Thedefault behaviorwhen no flags are given is the same as for Byte, Short, Integer, and Long.
The specification ofwidthis the same as defined for Byte, Short, Integer, and Long.
The precision is not applicable. If precision is specified then anIllegalFormatPrecisionException
will be thrown.
The following conversions may be applied tofloat,Float
,doubleandDouble
.
'e' | '\u0065' | Requires the output to be formatted usingcomputerized scientific notation. Thelocalization
algorithmis applied.
The formatting of the magnitudemdepends upon its value. Ifmis NaN or infinite, the literal strings "NaN" or "Infinity", respectively, will be output. These values are not localized. Ifmis positive-zero or negative-zero, then the exponent will be"+00". Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. The formatting of the sign is described in thelocalization algorithm. The formatting of the magnitudemdepends upon its value. Letnbe the unique integer such that 10n<=m< 10n+1; then letabe the mathematically exact quotient ofmand 10nso that 1 <=a< 10. The magnitude
is then represented as the integer part ofa, as a single decimal digit, followed by the decimal separator followed by decimal digits representing the fractional part ofa, followed by the exponent symbol'e'('\u0065'),
followed by the sign of the exponent, followed by a representation ofnas a decimal integer, as produced by the method The number of digits in the result for the fractional part ofmorais equal to the precision. If the precision is not specified then the default value is6. If the precision is less than the number of digits which would appear
after the decimal point in the string returned by If the','flag is given, then an |
'E' | '\u0045' | The upper-case variant of'e'. The exponent symbol will be'E'('\u0045'). |
'g' | '\u0067' | Requires the output to be formatted in general scientific notation as described below. Thelocalization
algorithmis applied.
After rounding for the precision, the formatting of the resulting magnitudemdepends on its value. Ifmis greater than or equal to 10-4but less than 10precisionthen it is represented indecimal format. Ifmis less than 10-4or greater than or equal to 10precision, then it is represented incomputerized scientific notation. The total number of significant digits inmis equal to the precision. If the precision is not specified, then the default value is6. If the precision is0, then it is taken to be1. If the'#'flag is given then an |
'G' | '\u0047' | The upper-case variant of'g'. |
'f' | '\u0066' | Requires the output to be formatted usingdecimal format. Thelocalization
algorithmis applied.
The result is a string that represents the sign and magnitude (absolute value) of the argument. The formatting of the sign is described in thelocalization algorithm. The formatting of the magnitudemdepends upon its value. IfmNaN or infinite, the literal strings "NaN" or "Infinity", respectively, will be output. These values are not localized. The magnitude is formatted as the integer part ofm, with no leading zeroes, followed by the decimal separator followed by one or more decimal digits representing the fractional part ofm. The number of digits in the result for the fractional part ofmorais equal to the precision. If the precision is not specified then the default value is6. If the precision is less than the number of digits which would appear
after the decimal point in the string returned by |
'a' | '\u0061' | Requires the output to be formatted in hexadecimal exponential form. No localization is applied.
The result is a string that represents the sign and magnitude (absolute value) of the argumentx. Ifxis negative or a negative-zero value then the result will begin with'-'('\u002d'). Ifxis positive or a positive-zero value and the'+'flag is given then the result will begin with'+'('\u002b'). The formatting of the magnitudemdepends upon its value.
If the'('or','flags are given, then a |
'A' | '\u0041' | The upper-case variant of'a'. The entire string representing the number will be converted to upper case including the'x'('\u0078') and'p'('\u0070'and all hexadecimal digits'a'-'f'('\u0061'-'\u0066'). |
Allflagsdefined for Byte, Short, Integer, and Long apply.
If the'#'flag is given, then the decimal separator will always be present.
If noflagsare given the default formatting is as follows:
- The output is right-justified within thewidth
- Negative numbers begin with a'-'
- Positive numbers and positive zero do not include a sign or extra leading space
- No grouping separators are included
- The decimal separator will only appear if a digit follows it
Thewidthis the minimum number of characters to be written to the output. This includes any signs, digits, grouping separators, decimal separators, exponential symbol, radix indicator, parentheses, and strings representing infinity and NaN as applicable. If the length of the converted value is less than the width then the output will be padded by spaces ('\u0020') until the total number of characters equals width. The padding is on the left by default. If the'-'flag is given then the padding will be on the right. If width is not specified then there is no minimum.
If theconversionis'e','E'or'f', then the precision is the number of digits after the decimal separator. If the precision is not specified, then it is assumed to be6.
If the conversion is'g'or'G', then the precision is the total number of significant digits in the resulting magnitude after rounding. If the precision is not specified, then the default value is6. If the precision is0, then it is taken to be1.
If the conversion is'a'or'A', then the precision is the number of hexadecimal digits after the decimal separator. If the precision is not provided, then all of the digits as returned byDouble.toHexString(double)
will
be output.
The following conversions may be appliedBigDecimal
.
'e' | '\u0065' | Requires the output to be formatted usingcomputerized scientific notation. Thelocalization
algorithmis applied.
The formatting of the magnitudemdepends upon its value. Ifmis positive-zero or negative-zero, then the exponent will be"+00". Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. The formatting of the sign is described in thelocalization algorithm. The formatting of the magnitudemdepends upon its value. Letnbe the unique integer such that 10n<=m< 10n+1; then letabe the mathematically exact quotient ofmand 10nso that 1 <=a< 10. The magnitude
is then represented as the integer part ofa, as a single decimal digit, followed by the decimal separator followed by decimal digits representing the fractional part ofa, followed by the exponent symbol'e'('\u0065'),
followed by the sign of the exponent, followed by a representation ofnas a decimal integer, as produced by the method The number of digits in the result for the fractional part ofmorais equal to the precision. If the precision is not specified then the default value is6. If the precision is less than the number of digits which would appear
after the decimal point in the string returned by If the','flag is given, then an |
'E' | '\u0045' | The upper-case variant of'e'. The exponent symbol will be'E'('\u0045'). |
'g' | '\u0067' | Requires the output to be formatted in general scientific notation as described below. Thelocalization
algorithmis applied.
After rounding for the precision, the formatting of the resulting magnitudemdepends on its value. Ifmis greater than or equal to 10-4but less than 10precisionthen it is represented indecimal format. Ifmis less than 10-4or greater than or equal to 10precision, then it is represented incomputerized scientific notation. The total number of significant digits inmis equal to the precision. If the precision is not specified, then the default value is6. If the precision is0, then it is taken to be1. If the'#'flag is given then an |
'G' | '\u0047' | The upper-case variant of'g'. |
'f' | '\u0066' | Requires the output to be formatted usingdecimal format. Thelocalization
algorithmis applied.
The result is a string that represents the sign and magnitude (absolute value) of the argument. The formatting of the sign is described in thelocalization algorithm. The formatting of the magnitudemdepends upon its value. The magnitude is formatted as the integer part ofm, with no leading zeroes, followed by the decimal separator followed by one or more decimal digits representing the fractional part ofm. The number of digits in the result for the fractional part ofmorais equal to the precision. If the precision is not specified then the default value is6. If the precision is less than the number of digits which would appear
after the decimal point in the string returned by |
Allflagsdefined for Byte, Short, Integer, and Long apply.
If the'#'flag is given, then the decimal separator will always be present.
Thedefault behaviorwhen no flags are given is the same as for Float and Double.
The specification ofwidthandprecisionis the same as defined for Float and Double.
Date/Time
This conversion may be applied tolong,Long
,Calendar
,
andDate
.
't' | '\u0074' | Prefix for date and time conversion characters. |
'T' | '\u0054' | The upper-case variant of't'. |
The following date and time conversion character suffixes are defined for the't'and'T'conversions. The types are similar to but not completely identical to those defined by GNUdateand POSIXstrftime(3c). Additional conversion types are provided to access Java-specific functionality (e.g.'L'for milliseconds within the second).
The following conversion characters are used for formatting times:
'H' | '\u0048' | Hour of the day for the 24-hour clock, formatted as two digits with a leading zero as necessary i.e.00 - 23.00corresponds to midnight. |
'I' | '\u0049' | Hour for the 12-hour clock, formatted as two digits with a leading zero as necessary, i.e.01 - 12.01corresponds to one o'clock (either morning or afternoon). |
'k' | '\u006b' | Hour of the day for the 24-hour clock, i.e.0 - 23.0corresponds to midnight. |
'l' | '\u006c' | Hour for the 12-hour clock, i.e.1 - 12.1corresponds to one o'clock (either morning or afternoon). |
'M' | '\u004d' | Minute within the hour formatted as two digits with a leading zero as necessary, i.e.00 - 59. |
'S' | '\u0053' | Seconds within the minute, formatted as two digits with a leading zero as necessary, i.e.00 - 60("60" is a special value required to support leap seconds). |
'L' | '\u004c' | Millisecond within the second formatted as three digits with leading zeros as necessary, i.e.000 - 999. |
'N' | '\u004e' | Nanosecond within the second, formatted as nine digits with leading zeros as necessary, i.e.000000000 - 999999999. The precision of this value is limited by the resolution of the underlying operating system or hardware. |
'p' | '\u0070' | Locale-specificmorning or afternoonmarker in lower case, e.g."am" or "pm". Use of the conversion prefix'T'forces this output to upper case. (Note that'p'produces lower-case output. This is different from GNUdateand POSIXstrftime(3c)which produce upper-case output.) |
'z' | '\u007a' | RFC 822style numeric time zone offset from GMT, e.g.-0800. |
'Z' | '\u005a' | A string representing the abbreviation for the time zone. |
's' | '\u0073' | Seconds since the beginning of the epoch starting at 1 January 197000:00:00UTC, i.e.Long.MIN_VALUE/1000toLong.MAX_VALUE/1000. |
'Q' | '\u004f' | Milliseconds since the beginning of the epoch starting at 1 January 197000:00:00UTC, i.e.Long.MIN_VALUEtoLong.MAX_VALUE. The precision of this value is limited by the resolution of the underlying operating system or hardware. |
The following conversion characters are used for formatting dates:
'B' | '\u0042' | Locale-specificfull month name, e.g."January","February". |
'b' | '\u0062' | Locale-specificabbreviated month name, e.g."Jan","Feb". |
'h' | '\u0068' | Same as'b'. |
'A' | '\u0041' | Locale-specific full name of theday of the week, e.g."Sunday","Monday" |
'a' | '\u0061' | Locale-specific short name of theday of the week, e.g."Sun","Mon" |
'C' | '\u0043' | Four-digit year divided by100, formatted as two digits with leading zero as necessary, i.e.00 - 99 |
'Y' | '\u0059' | Year, formatted to at least four digits with leading zeros as necessary, e.g.0092equals92CE for the Gregorian calendar. |
'y' | '\u0079' | Last two digits of the year, formatted with leading zeros as necessary, i.e.00 - 99. |
'j' | '\u006a' | Day of year, formatted as three digits with leading zeros as necessary, e.g.001 - 366for the Gregorian calendar.001corresponds to the first day of the year. |
'm' | '\u006d' | Month, formatted as two digits with leading zeros as necessary, i.e.01 - 13, where "01" is the first month of the year and ("13" is a special value required to support lunar calendars). |
'd' | '\u0064' | Day of month, formatted as two digits with leading zeros as necessary, i.e.01 - 31, where "01" is the first day of the month. |
'e' | '\u0065' | Day of month, formatted as two digits, i.e.1 - 31where "1" is the first day of the month. |
The following conversion characters are used for formatting common date/time compositions.
'R' | '\u0052' | Time formatted for the 24-hour clock as"%tH:%tM" |
'T' | '\u0054' | Time formatted for the 24-hour clock as"%tH:%tM:%tS". |
'r' | '\u0072' | Time formatted for the 12-hour clock as"%tI:%tM:%tS %Tp". The location of the morning or afternoon marker ('%Tp') may be locale-dependent. |
'D' | '\u0044' | Date formatted as"%tm/%td/%ty". |
'F' | '\u0046' | ISO 8601complete date formatted as"%tY-%tm-%td". |
'c' | '\u0063' | Date and time formatted as"%ta %tb %td %tT %tZ %tY", e.g."Sun Jul 20 16:17:00 EDT 1969". |
The'-'flag defined forGeneral conversionsapplies. If the'#'flag is given, then aFormatFlagsConversionMismatchException
will
be thrown.
Thewidthis the minimum number of characters to be written to the output. If the length of the converted value is less than thewidththen the output will be padded by spaces ('\u0020') until the total number of characters equals width. The padding is on the left by default. If the'-'flag is given then the padding will be on the right. If width is not specified then there is no minimum.
The precision is not applicable. If the precision is specified then anIllegalFormatPrecisionException
will be thrown.
Percent
The conversion does not correspond to any argument.
'%' | The result is a literal'%'('\u0025')
Thewidthis the minimum number of characters to be written to the output including the'%'. If the length of the converted value is less than thewidththen the output will be padded by spaces ('\u0020') until the total number of characters equals width. The padding is on the left. If width is not specified then just the'%'is output. The'-'flag defined forGeneral conversionsapplies. If any other flags are provided, then a The precision is not applicable. If the precision is specified an |
Line Separator
The conversion does not correspond to any argument.
'n' | the platform-specific line separator as returned bySystem.getProperty("line.separator") . |
Flags, width, and precision are not applicable. If any are provided anIllegalFormatFlagsException
,IllegalFormatWidthException
,
andIllegalFormatPrecisionException
, respectively will be thrown.
Argument Index
Format specifiers can reference arguments in three ways:
-
Explicit indexingis used when the format specifier contains an argument index. The argument index is a decimal integer indicating the position of the argument in the argument list. The first argument is referenced by "1$", the second
by "2$", etc. An argument may be referenced more than once.
For example:
formatter.format("%4$s %3$s %2$s %1$s %4$s %3$s %2$s %1$s", "a", "b", "c", "d") // -> "d c b a d c b a"
-
Relative indexingis used when the format specifier contains a'<'('\u003c') flag which causes the argument for the previous format specifier to be re-used. If there is no previous argument, then a
MissingFormatArgumentException
is thrown.formatter.format("%s %s %<s %<s", "a", "b", "c", "d") // -> "a b b b" // "c" and "d" are ignored because they are not referenced
-
Ordinary indexingis used when the format specifier contains neither an argument index nor a'<'flag. Each format specifier which uses ordinary indexing is assigned a sequential implicit index into argument list which is independent of
the indices used by explicit or relative indexing.
formatter.format("%s %s %s %s", "a", "b", "c", "d") // -> "a b c d"
It is possible to have a format string which uses all forms of indexing, for example:
formatter.format("%2$s %s %<s %s", "a", "b", "c", "d") // -> "b a a b" // "c" and "d" are ignored because they are not referenced
The maximum number of arguments is limited by the maximum dimension of a Java array as defined by theJava Virtual Machine Specification. If the argument index is does not correspond to an available argument,
then aMissingFormatArgumentException
is thrown.
If there are more arguments than format specifiers, the extra arguments are ignored.
Unless otherwise specified, passing anullargument to any method or constructor in this class will cause aNullPointerException
to
be thrown.
static class
|
Formatter.BigDecimalLayoutForm |
Formatter() Constructs a new formatter. |
Formatter(Appendablea) Constructs a new formatter with the specified destination. |
Formatter(Appendablea,Localel) Constructs a new formatter with the specified destination and locale. |
Formatter(Filefile) Constructs a new formatter with the specified file. |
Formatter(Filefile,Stringcsn) Constructs a new formatter with the specified file and charset. |
Formatter(Filefile,Stringcsn,Localel) Constructs a new formatter with the specified file, charset, and locale. |
Formatter(Localel) Constructs a new formatter with the specified locale. |
Formatter(OutputStreamos) Constructs a new formatter with the specified output stream. |
Formatter(OutputStreamos,Stringcsn) Constructs a new formatter with the specified output stream and charset. |
Formatter(OutputStreamos,Stringcsn,Localel) Constructs a new formatter with the specified output stream, charset, and locale. |
Formatter(PrintStreamps) Constructs a new formatter with the specified print stream. |
Formatter(StringfileName) Constructs a new formatter with the specified file name. |
Formatter(StringfileName,Stringcsn) Constructs a new formatter with the specified file name and charset. |
Formatter(StringfileName,Stringcsn,Localel) Constructs a new formatter with the specified file name, charset, and locale. |
void
|
close() Closes this formatter. |
void
|
flush() Flushes this formatter. |
Formatter
|
format(Localel,Stringformat,Object...
args) Writes a formatted string to this object's destination using the specified locale, format string, and arguments. |
Formatter
|
format(Stringformat,Object...
args) Writes a formatted string to this object's destination using the specified format string and arguments. |
IOException
|
ioException() Returns theIOExceptionlast thrown by this formatter's Appendable . |
Locale
|
locale() Returns the locale set by the construction of this formatter. |
Appendable
|
out() Returns the destination for the output. |
String
|
toString() Returns the result of invokingtoString()on the destination for the output. |
clone,equals,finalize,getClass,hashCode,notify,notifyAll,wait,wait,wait |
Formatter
publicFormatter()
The destination of the formatted output is aStringBuilder
which may be retrieved by invokingout()
and
whose current content may be converted into a string by invokingtoString()
. The locale used is thedefault
localefor this instance of the Java virtual machine.
Formatter
publicFormatter(Appendablea)
The locale used is thedefault localefor this instance of the Java virtual machine.
a
- Destination for the formatted output. Ifaisnullthen aStringBuilder
will
be created.Formatter
publicFormatter(Localel)
The destination of the formatted output is aStringBuilder
which may be retrieved by invokingout()
and
whose current content may be converted into a string by invokingtoString()
.
l
- Thelocaleto apply during formatting. Iflisnullthen no localization is applied.Formatter
publicFormatter(Appendablea,Localel)
a
- Destination for the formatted output. Ifaisnullthen aStringBuilder
will
be created.l
- Thelocaleto apply during formatting. Iflisnullthen no localization is applied.Formatter
publicFormatter(StringfileName) throwsFileNotFoundException
The charset used is thedefault charsetfor this instance of the Java virtual machine.
The locale used is thedefault localefor this instance of the Java virtual machine.
fileName
- The name of the file to use as the destination of this formatter. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.SecurityException
- If a security manager is present andcheckWrite(fileName)
denies
write access to the fileFileNotFoundException
- If the given file name does not denote an existing, writable regular file and a new regular
file of that name cannot be created, or if some other error occurs while opening or creating the fileFormatter
publicFormatter(StringfileName,Stringcsn) throwsFileNotFoundException,UnsupportedEncodingException
The locale used is thedefault localefor this instance of the Java virtual machine.
fileName
- The name of the file to use as the destination of this formatter. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.csn
- The name of a supportedcharset
FileNotFoundException
- If the given file name does not denote an existing, writable regular file and a new regular
file of that name cannot be created, or if some other error occurs while opening or creating the fileSecurityException
- If a security manager is present andcheckWrite(fileName)
denies
write access to the fileUnsupportedEncodingException
- If the named charset is not supportedFormatter
publicFormatter(StringfileName,Stringcsn,Localel) throwsFileNotFoundException,UnsupportedEncodingException
fileName
- The name of the file to use as the destination of this formatter. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.csn
- The name of a supportedcharset
l
- Thelocaleto apply during formatting. Iflisnullthen no localization is applied.FileNotFoundException
- If the given file name does not denote an existing, writable regular file and a new regular
file of that name cannot be created, or if some other error occurs while opening or creating the fileSecurityException
- If a security manager is present andcheckWrite(fileName)
denies
write access to the fileUnsupportedEncodingException
- If the named charset is not supportedFormatter
publicFormatter(Filefile) throwsFileNotFoundException
The charset used is thedefault charsetfor this instance of the Java virtual machine.
The locale used is thedefault localefor this instance of the Java virtual machine.
file
- The file to use as the destination of this formatter. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.SecurityException
- If a security manager is present andcheckWrite(file.getPath())
denies
write access to the fileFileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular
file of that name cannot be created, or if some other error occurs while opening or creating the fileFormatter
publicFormatter(Filefile,Stringcsn) throwsFileNotFoundException,UnsupportedEncodingException
The locale used is thedefault localefor this instance of the Java virtual machine.
file
- The file to use as the destination of this formatter. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.csn
- The name of a supportedcharset
FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular
file of that name cannot be created, or if some other error occurs while opening or creating the fileSecurityException
- If a security manager is present andcheckWrite(file.getPath())
denies
write access to the fileUnsupportedEncodingException
- If the named charset is not supportedFormatter
publicFormatter(Filefile,Stringcsn,Localel) throwsFileNotFoundException,UnsupportedEncodingException
file
- The file to use as the destination of this formatter. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.csn
- The name of a supportedcharset
l
- Thelocaleto apply during formatting. Iflisnullthen no localization is applied.FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular
file of that name cannot be created, or if some other error occurs while opening or creating the fileSecurityException
- If a security manager is present andcheckWrite(file.getPath())
denies
write access to the fileUnsupportedEncodingException
- If the named charset is not supportedFormatter
publicFormatter(PrintStreamps)
The locale used is thedefault localefor this instance of the Java virtual machine.
Characters are written to the givenPrintStream
object and are therefore encoded using that object's charset.
ps
- The stream to use as the destination of this formatter.Formatter
publicFormatter(OutputStreamos)
The charset used is thedefault charsetfor this instance of the Java virtual machine.
The locale used is thedefault localefor this instance of the Java virtual machine.
os
- The output stream to use as the destination of this formatter. The output will be buffered.Formatter
publicFormatter(OutputStreamos,Stringcsn) throwsUnsupportedEncodingException
The locale used is thedefault localefor this instance of the Java virtual machine.
os
- The output stream to use as the destination of this formatter. The output will be buffered.csn
- The name of a supportedcharset
UnsupportedEncodingException
- If the named charset is not supportedFormatter
publicFormatter(OutputStreamos,Stringcsn,Localel) throwsUnsupportedEncodingException
os
- The output stream to use as the destination of this formatter. The output will be buffered.csn
- The name of a supportedcharset
l
- Thelocaleto apply during formatting. Iflisnullthen no localization is applied.UnsupportedEncodingException
- If the named charset is not supportedlocale
publicLocalelocale()
Theformat
method for this object which has a locale argument does not change this value.
FormatterClosedException
- If this formatter has been closed by invoking itsclose()
methodout
publicAppendableout()
FormatterClosedException
- If this formatter has been closed by invoking itsclose()
methodtoString
publicStringtoString()
StringBuilder
then
retrieves the resultant string:
Formatter f = new Formatter(); f.format("Last reboot at %tc", lastRebootDate); String s = f.toString(); // -> s == "Last reboot at Sat Jan 01 00:00:00 PST 2000"
An invocation of this method behaves in exactly the same way as the invocation
out().toString()
Depending on the specification oftoStringfor theAppendable
, the returned string may or may not contain
the characters written to the destination. For instance, buffers typically return their contents intoString(), but streams cannot since the data is discarded.
toString
in classObject
FormatterClosedException
- If this formatter has been closed by invoking itsclose()
methodflush
public voidflush()
Flushable
interface, itsflushmethod will
be invoked.
Flushing a formatter writes any buffered output in the destination to the underlying stream.
flush
in interfaceFlushable
FormatterClosedException
- If this formatter has been closed by invoking itsclose()
methodclose
public voidclose()
Closeable
interface, itsclosemethod will be
invoked.
Closing a formatter allows it to release resources it may be holding (such as open files). If the formatter is already closed, then invoking this method has no effect.
Attempting to invoke any methods exceptioException()
in this formatter after it has been closed will result in aFormatterClosedException
.
close
in interfaceCloseable
ioException
publicIOExceptionioException()
Appendable
.
If the destination'sappend()method never throwsIOException, then this method will always returnnull.
format
publicFormatterformat(Stringformat,Object... args)
format
- A format string as described inFormat string syntax.args
- Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The maximum number of arguments is limited by the maximum dimension of a Java array
as defined by theJava Virtual Machine Specification.IllegalFormatException
- If a format string contains an illegal syntax, a format specifier that is incompatible
with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see theDetailssection
of the formatter class specification.FormatterClosedException
- If this formatter has been closed by invoking itsclose()
methodformat
publicFormatterformat(Localel,Stringformat,Object... args)
l
- Thelocaleto apply during formatting. Iflisnullthen no localization is applied. This
does not change this object's locale that was set during construction.format
- A format string as described inFormat string syntax
args
- Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The maximum number of arguments is limited by the maximum dimension of a Java array
as defined by theJava Virtual Machine Specification
IllegalFormatException
- If a format string contains an illegal syntax, a format specifier that is incompatible
with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see theDetailssection
of the formatter class specification.FormatterClosedException
- If this formatter has been closed by invoking itsclose()
method
|
Java™ Platform Standard Ed. 6 |
||||||||
PREV CLASSNEXT CLASS | FRAMESNO FRAMESAll Classes | ||||||||
SUMMARY:NESTED| FIELD |CONSTR|METHOD | DETAIL: FIELD |CONSTR|METHOD |
Submit a bug or feature
For further API reference and developer documentation, seeJava SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject tolicense terms. Also see thedocumentation redistribution policy.
相关推荐
C#Formatter 是一个Visual Studio 2010/2012/2013外接程序,可改善您的C#编程体验,使您能够清理和美化C#代码的外观。 目前,该软件提供以下功能: 美化代码,在每个类,方法,属性或区域的顶部添加分隔符注释 ...
SD Memory Card Formatter(SD 存储卡格式化程序)根据 SD 协会 (SDA) 创建的 SD 文件系统规范格式化 SD 存储卡、SDHC 存储卡和 SDXC 存储卡(分别为 SD/SDHC/SDXC 卡)。 强烈建议使用 SD Memory Card Formatter 来...
* A sample source file for the code formatter preview */ package mypackage; import java.util.LinkedList; public class MyIntStack { private final LinkedList fStack; public MyIntStack() { fStack...
1、本资源已经对源码NPM工程打包为sql-formatter.min.js 文件可直接引入使用 2、具体说明可见下载后压缩包中的 说明.text 文件 3、相关博客文章 https://blog.csdn.net/guzuoi/article/details/111151290
Fat32Formatter 磁盘格式化工具 FAT32 文件系统格式化图形界面工具,支持Windows 下FAT32 格式化单一分区 2000GB,是对 Windows Vista/Seven和XP 磁盘管理控制台的补充。 在 Windows2000/XP/Vista/Seven 下用其磁盘...
1.SD Formatter、是以SDA发行的SD File System Specification为依据,对SD存储卡、SDHC存储卡以及 SDXC存储卡(以下简称SD/SDHC/SDXC卡)进行格式化。 2.SD Formatter对SD/SDHC/SDXC卡进行格式化的目的,就是为了最大...
SD Memory Card Formatter for Mac 是专为Mac用户设计的SD存储卡格式化工具。它具有简单易用的界面,可快速而安全地格式化SD、SDHC、SDXC和MicroSD卡,以准备存储新数据。这款软件不仅能提高存储卡的性能,还有助于...
1.插件安装:Androidstudio插件市场安装Adapter for Eclipse Code Formatter 2.插件配置,在附件截图中 3.xml配置文件在附件中 4.默认快捷键 CTRL+ALT+L快速格式化代码,比如缩进、对齐、空格等
eclipseformatter格式化文件
code stytle code formatter
自己用的一个code formatter编码风格
Eclipse Code Formatter 可直接导入使用,直接下载。为解决网络问题。源码地址:https://github.com/alibaba/p3c/tree/master/p3c-formatter
eclipse配置代码格式的codestyle.xml文件,在Eclipse或MyEclipse中点击Window -> Preferences菜单,点击左侧的“Java”->“Code Style”->Formatter中import即可
exam formatter 是个不错的工具
Notepad++ sql格式化插件 Poor Man's T-SQL Formatter SqlFormatterNppPlugin.1.5.1
IDEA与Eclipse统一代码风格codeformatter使用文档 为了使在两个IDE中使用统一
软件介绍: P_formatter_v16443群联低格工具,可以用于量产成固定磁盘后的修复。或者量产工具不识别U盘的时候也可以试试。测试PS2251-32可用。
formatter-profile.xm
Formatter SiliconPower是当前新版本的群联PS2251主控U盘格式化修复工具,可以在量产失败后使用它恢复你的U盘,或者U盘出问题的时候,量产前使用, 仅测试使用
SD Formatter 在我的树莓派做系统的时候用俩格式化SD卡,仅供学习交流,支持正版。修改积分为1积分