java.text.FieldPosition
java.lang.Object
None
None
New as of JDK 1.1
The FieldPosition class encapsulates information about fields in formatted output. The fields in a particular type of formatted output are identified by constants. A FieldPosition object contains its field type and the field's position within the formatted output. The field position is specified by the index of the first character in the field and the index of the last character in the field.
You can use a FieldPosition object to find the position of a particular field in a formatted string. Consider the following code:
NumberFormat nf = NumberFormat.getInstance(); StringBuffer sb = new StringBuffer(); FieldPosition fp = new FieldPosition(NumberFormat.FRACTION_FIELD); nf.format(-1234.56, sb, fp); System.out.println(new String(sb)); System.out.println("FRACTION_FIELD goes from " + fp.getBeginIndex() + " to " + fp.getEndIndex() + ".");
This code produces the following output:
-1,234.56 FRACTION_FIELD goes from 7 to 9.
public class java.text.FieldPosition extends java.lang.Object { // Constructors public FieldPosition(int field); // Instance Methods public int getBeginIndex(); public int getEndIndex(); public int getField(); }
A field constant.
This constructor creates a FieldPosition object that represents the given field.
The beginning index.
This method returns the beginning index of the field that is represented by this FieldPosition.
The ending index of this FieldPosition.
This method returns the ending index of the field that is represented by this FieldPosition.
The field constant of this FieldPosition.
This method returns the field constant of this FieldPosition.
Method | Inherited From | Method | Inherited From |
---|---|---|---|
clone() |
Object |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
DateFormat, Format, MessageFormat, NumberFormat, ParsePosition, String