# 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)

*** ** * ** ***


```
public final 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/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/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/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/androidx/health/connect/client/records/Record` without specifying zoneOffset will assume the current system zone offset at query time.

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html startTime)` Creates a `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` for a time range after the given `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.Instant)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#after(java.time.LocalDateTime)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/LocalDateTime.html startTime)` Creates a `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` for a time range after the given `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter.Companion#after(java.time.LocalDateTime)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#before(java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html endTime)` Creates a `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` for a time range until the given `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.Instant)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#before(java.time.LocalDateTime)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/LocalDateTime.html endTime)` Creates a `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` for a time range until the given `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter.Companion#before(java.time.LocalDateTime)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.Instant,java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html startTime, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html endTime)` Creates a `https://developer.android.com/reference/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). |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#between(java.time.LocalDateTime,java.time.LocalDateTime)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/LocalDateTime.html startTime, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/LocalDateTime.html endTime)` Creates a `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter` for a time range within the `https://developer.android.com/reference/java/time/LocalDateTime.html` range \[startTime, endTime). |
| `boolean` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/time/TimeRangeFilter#hashCode()()` |

## Public methods

### after

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

```
public static final @NonNull TimeRangeFilter after(@NonNull Instant startTime)
```

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

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

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

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

```
public static final @NonNull TimeRangeFilter after(@NonNull LocalDateTime startTime)
```

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

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

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

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

```
public static final @NonNull TimeRangeFilter before(@NonNull Instant endTime)
```

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

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

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

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

```
public static final @NonNull TimeRangeFilter before(@NonNull LocalDateTime endTime)
```

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

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

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

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

```
public static final @NonNull TimeRangeFilter between(@NonNull Instant startTime, @NonNull Instant endTime)
```

Creates a `https://developer.android.com/reference/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/androidx/health/connect/client/records/Record` at 2pm(UTC+1), crossed a time zone and created a new `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html startTime` | start time of the filter. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html endTime` | end time of the filter. |

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

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

```
public static final @NonNull TimeRangeFilter between(@NonNull LocalDateTime startTime, @NonNull LocalDateTime endTime)
```

Creates a `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/LocalDateTime.html startTime` | start time of the filter. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/LocalDateTime.html endTime` | end time of the filter. |

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

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

### equals

```
public boolean equals(Object other)
```

### hashCode

```
public int hashCode()
```