# TimeRangeFilter

Artifact: [androidx.health.connect:connect-client](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/time/TimeRangeFilter.kt+class:androidx.health.connect.client.time.TimeRangeFilter) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter "View this page in Java")


```
class TimeRangeFilter
```

<br />

*** ** * ** ***

Specification of time range for read and delete requests.

The time range can be specified in one of the following ways:

- use `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.Instant,java.time.Instant)` for a closed-ended time range, inclusive-exclusive;

- use `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#before(java.time.Instant)` for a open-ended start time range, end time is exclusive;

- use `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)` for a open-ended end time range, start time is inclusive.

Time can be specified in one of the two ways:

- use `https://developer.android.com/reference/java/time/Instant.html` for a specific point in time such as "2021-01-03 at 10:00 UTC+1";

- use `https://developer.android.com/reference/java/time/LocalDateTime.html` for a user experienced time concept such as "2021-01-03 at 10 o'clock", without knowing which time zone the user was at that time. `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record` without specifying zoneOffset will assume the current system zone offset at query time.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)(startTime: https://developer.android.com/reference/java/time/Instant.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range after the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.Instant)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.LocalDateTime)(startTime: https://developer.android.com/reference/java/time/LocalDateTime.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range after the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.LocalDateTime)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#before(java.time.Instant)(endTime: https://developer.android.com/reference/java/time/Instant.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range until the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.Instant)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#before(java.time.LocalDateTime)(endTime: https://developer.android.com/reference/java/time/LocalDateTime.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range until the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.LocalDateTime)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.Instant,java.time.Instant)(startTime: https://developer.android.com/reference/java/time/Instant.html, endTime: https://developer.android.com/reference/java/time/Instant.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range within the `https://developer.android.com/reference/java/time/Instant.html` time range \[startTime, endTime). |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.LocalDateTime,java.time.LocalDateTime)(startTime: https://developer.android.com/reference/java/time/LocalDateTime.html, endTime: https://developer.android.com/reference/java/time/LocalDateTime.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range within the `https://developer.android.com/reference/java/time/LocalDateTime.html` range \[startTime, endTime). |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#hashCode()()` |

## Public companion functions

### after

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
fun after(startTime: Instant): TimeRangeFilter
```

Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range after the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.Instant)`.

| Parameters |
|---|---|
| `startTime: https://developer.android.com/reference/java/time/Instant.html` | start time of the filter. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for filtering `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.Instant,java.time.Instant)` | for closed-ended time range. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.Instant)` |

### after

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
fun after(startTime: LocalDateTime): TimeRangeFilter
```

Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range after the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.LocalDateTime)`.

| Parameters |
|---|---|
| `startTime: https://developer.android.com/reference/java/time/LocalDateTime.html` | start time of the filter. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for filtering `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.Instant,java.time.Instant)` | for closed-ended time range. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.LocalDateTime)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.LocalDateTime)` |

### before

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
fun before(endTime: Instant): TimeRangeFilter
```

Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range until the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.Instant)`.

| Parameters |
|---|---|
| `endTime: https://developer.android.com/reference/java/time/Instant.html` | end time of the filter. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for filtering `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.Instant,java.time.Instant)` | for closed-ended time range. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.Instant)` |

### before

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
fun before(endTime: LocalDateTime): TimeRangeFilter
```

Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range until the given `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.LocalDateTime)`.

| Parameters |
|---|---|
| `endTime: https://developer.android.com/reference/java/time/LocalDateTime.html` | end time of the filter. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for filtering `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.Instant,java.time.Instant)` | for closed-ended time range. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.LocalDateTime)` |

### between

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
fun between(startTime: Instant, endTime: Instant): TimeRangeFilter
```

Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range within the `https://developer.android.com/reference/java/time/Instant.html` time range \[startTime, endTime).

If user created a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record` at 2pm(UTC+1), crossed a time zone and created a new `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record` at 3pm(UTC). Filtering between 2pm(UTC) and 6pm(UTC) will include the record at 3pm(UTC) but not the record at 2pm(UTC+1), because 2pm(UTC+1) happened before 2pm(UTC).

| Parameters |
|---|---|
| `startTime: https://developer.android.com/reference/java/time/Instant.html` | start time of the filter. |
| `endTime: https://developer.android.com/reference/java/time/Instant.html` | end time of the filter. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for filtering `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#before(java.time.Instant)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#between(java.time.Instant,java.time.Instant)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#between(java.time.Instant,java.time.Instant)`. |

### between

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
fun between(startTime: LocalDateTime, endTime: LocalDateTime): TimeRangeFilter
```

Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for a time range within the `https://developer.android.com/reference/java/time/LocalDateTime.html` range \[startTime, endTime).

| Parameters |
|---|---|
| `startTime: https://developer.android.com/reference/java/time/LocalDateTime.html` | start time of the filter. |
| `endTime: https://developer.android.com/reference/java/time/LocalDateTime.html` | end time of the filter. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` | a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter` for filtering `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/Record`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#before(java.time.Instant)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#between(java.time.LocalDateTime,java.time.LocalDateTime)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)` | for time range with open-ended `https://developer.android.com/reference/kotlin/androidx/health/connect/client/time/TimeRangeFilter.Companion#between(java.time.LocalDateTime,java.time.LocalDateTime)`. |

## Public functions

### equals

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

### hashCode

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