ParsePosition setErrorIndex Example
ParsePosition class setErrorIndex example. This example shows you how to use setErrorIndex method.
ParsePosition class setErrorIndex example. public void setErrorIndex(int ei) Set the index at which a parse error occurred. Formatters should set this before returning an error code from their parseObject method. The default value is -1 if this is not set.
Here is the code
/*
* @ # SetErrorIndex.java
* A class representing use to setErrorIndex method of
* ParsePosition class in java.text package
* version 14 June 2008
* author Rose India
*/
import java.text.*;
public class SetErrorIndex {
public static void main(String[] args) {
// create instance of parse position
ParsePosition p = new ParsePosition(10);
//get error index, or -1 if the error index has not been set.
System.out.println("Error index " + p.getErrorIndex());
//set error index
p.setErrorIndex(1);
System.out.println("Error index " + p.getErrorIndex());
}
} |
Output
Error index -1
Error index 1 |
|