Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/text/ParsePosition#pubctors) \| [Methods](https://developer.android.com/reference/java/text/ParsePosition#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/text/ParsePosition#inhmethods)

# ParsePosition

` public class ParsePosition `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.text.ParsePosition |

<br />

*** ** * ** ***

`ParsePosition` is a simple class used by `Format` and its subclasses to keep track of the current position during parsing. The `parseObject` method in the various `Format` classes requires a `ParsePosition` object as an argument.

By design, as you parse through a string with different formats, you can use the same `ParsePosition`, since the index parameter records the current position.
**See also:**

- `https://developer.android.com/reference/java/text/Format`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/text/ParsePosition#ParsePosition(int)(int index) ` Create a new ParsePosition with the given initial index. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/java/text/ParsePosition#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Overrides equals |
| ` int` | ` https://developer.android.com/reference/java/text/ParsePosition#getErrorIndex()() ` Retrieve the index at which an error occurred, or -1 if the error index has not been set. |
| ` int` | ` https://developer.android.com/reference/java/text/ParsePosition#getIndex()() ` Retrieve the current parse position. |
| ` int` | ` https://developer.android.com/reference/java/text/ParsePosition#hashCode()() ` Returns a hash code for this ParsePosition. |
| ` void` | ` https://developer.android.com/reference/java/text/ParsePosition#setErrorIndex(int)(int ei) ` Set the index at which a parse error occurred. |
| ` void` | ` https://developer.android.com/reference/java/text/ParsePosition#setIndex(int)(int index) ` Set the current parse position. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/text/ParsePosition#toString()() ` Return a string representation of this ParsePosition. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### ParsePosition

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ParsePosition (int index)
```

Create a new ParsePosition with the given initial index.

<br />

| Parameters ||
|---|---|
| `index` | `int`: initial index <br /> |

## Public methods

### equals

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object obj)
```

Overrides equals

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### getErrorIndex

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getErrorIndex ()
```

Retrieve the index at which an error occurred, or -1 if the error index has not been set.

<br />

| Returns ||
|---|---|
| `int` | the index at which an error occurred <br /> |

### getIndex

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getIndex ()
```

Retrieve the current parse position. On input to a parse method, this is the index of the character at which parsing will begin; on output, it is the index of the character following the last character parsed.

<br />

| Returns ||
|---|---|
| `int` | the current parse position <br /> |

### hashCode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a hash code for this ParsePosition.

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object <br /> |

### setErrorIndex

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `ei` | `int`: the index at which an error occurred <br /> |

### setIndex

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setIndex (int index)
```

Set the current parse position.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the current parse position <br /> |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Return a string representation of this ParsePosition.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of this object <br /> |