# DateInterval

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

# DateInterval

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/icu/util/DateInterval "View this page in Java")  

```
class DateInterval : Serializable
```

|---|----------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                 ||
| ↳ | [android.icu.util.DateInterval](https://developer.android.com/reference/kotlin/android/icu/util/DateInterval#) |

This class represents date interval. It is a pair of long representing from date 1 to date 2.

## Summary

|                                                                                                                                                                        Public constructors                                                                                                                                                                        ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [DateInterval](https://developer.android.com/reference/kotlin/android/icu/util/DateInterval#DateInterval(kotlin.Long,%20kotlin.Long))`(`from:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`, `to:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Constructor given from date and to date. |

|                                                                                                                                             Public methods                                                                                                                                              ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](https://developer.android.com/reference/kotlin/android/icu/util/DateInterval#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Override equals |
| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)       | [getFromDate](https://developer.android.com/reference/kotlin/android/icu/util/DateInterval#getFromDate())`()` Get the from date.                                                                                    |
| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)       | [getToDate](https://developer.android.com/reference/kotlin/android/icu/util/DateInterval#getToDate())`()` Get the to date.                                                                                          |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [hashCode](https://developer.android.com/reference/kotlin/android/icu/util/DateInterval#hashCode())`()` Override hashcode                                                                                           |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)   | [toString](https://developer.android.com/reference/kotlin/android/icu/util/DateInterval#toString())`()` Override toString                                                                                           |

## Public constructors

### DateInterval

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

```
DateInterval(
    from: Long, 
    to: Long)
```

Constructor given from date and to date.

|                                                      Parameters                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------|
| `from` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):The from date in date interval. |
| `to`   | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):The to date in date interval.   |

## Public methods

### equals

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

```
fun equals(other: Any?): Boolean
```

Override equals

|                     Parameters                     ||
|-------|---------------------------------------------|
| `obj` | the reference object with which to compare. |

|                                                                           Return                                                                           ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this object is the same as the obj argument;`false`otherwise. |

### getFromDate

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

```
fun getFromDate(): Long
```

Get the from date.

|                                                    Return                                                    ||
|------------------------------------------------------------------------------|--------------------------------|
| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | the from date in dateInterval. |

### getToDate

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

```
fun getToDate(): Long
```

Get the to date.

|                                                   Return                                                   ||
|------------------------------------------------------------------------------|------------------------------|
| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | the to date in dateInterval. |

### hashCode

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

```
fun hashCode(): Int
```

Override hashcode

|                                                     Return                                                     ||
|----------------------------------------------------------------------------|------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hash code value for this object. |

### toString

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

```
fun toString(): String
```

Override toString

|                                                          Return                                                          ||
|----------------------------------------------------------------------------------|----------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |