加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090226002845/http://developer.android.com:80/reference/java/text/Format.html
public abstract class

Format

extends Object
implements Serializable Cloneable
java.lang.Object
   ↳ java.text.Format
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Format is the abstract superclass of classes which format and parse objects according to Locale specific rules.

Summary

Nested Classes
public abstract class Format.Field This inner class is used to represent Format attributes in the AttributedCharacterIterator that formatToCharacterIterator() method returns in the Format subclasses. 
Public Constructors
Format()
Constructs a new instance of Format.
Public Methods
Object clone()
Returns a copy of this Format.
abstract StringBuffer format(Object object, StringBuffer buffer, FieldPosition field)
Formats the specified object into the specified StringBuffer using the rules of this Format.
final String format(Object object)
Formats the specified object using the rules of this Format.
AttributedCharacterIterator formatToCharacterIterator(Object object)
Formats the specified object using the rules of this format and returns an AttributedCharacterIterator with the formatted String and no attributes.
abstract Object parseObject(String string, ParsePosition position)
Parse the specified String starting at the index specified by the ParsePosition.
Object parseObject(String string)
Parse the specified String using the rules of this Format.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Format ()

Constructs a new instance of Format.

Public Methods

public Object clone ()

Returns a copy of this Format.

Returns
  • a shallow copy of this Format
See Also

public abstract StringBuffer format (Object object, StringBuffer buffer, FieldPosition field)

Formats the specified object into the specified StringBuffer using the rules of this Format. If the field specified by the FieldPosition is formatted, set the begin and end index of the formatted field in the FieldPosition.

Parameters
object the object to format
buffer the StringBuffer
field the FieldPosition
Returns
  • the StringBuffer parameter buffer
Throws
IllegalArgumentException when the object cannot be formatted by this Format

public final String format (Object object)

Formats the specified object using the rules of this Format.

Parameters
object the object to format
Returns
  • the formatted String
Throws
IllegalArgumentException when the object cannot be formatted by this Format

public AttributedCharacterIterator formatToCharacterIterator (Object object)

Formats the specified object using the rules of this format and returns an AttributedCharacterIterator with the formatted String and no attributes.

Subclasses should return an AttributedCharacterIterator with the appropriate attributes.

Parameters
object the object to format
Returns
  • an AttributedCharacterIterator with the formatted object and attributes
Throws
IllegalArgumentException when the object cannot be formatted by this Format

public abstract Object parseObject (String string, ParsePosition position)

Parse the specified String starting at the index specified by the ParsePosition. If the string is successfully parsed, the index of the ParsePosition is updated to the index following the parsed text.

Parameters
string the String to parse
position the ParsePosition, updated on return with the index following the parsed text, or on error the index is unchanged and the error index is set to the index where the error occurred
Returns
  • the object resulting from the parse, or null if there is an error

public Object parseObject (String string)

Parse the specified String using the rules of this Format.

Parameters
string the String to parse
Returns
  • the object resulting from the parse
Throws
ParseException when an error occurs during parsing