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

# TimeUtils

*** ** * ** ***

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

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

<br />

*** ** * ** ***

A class containing utility methods related to time zones.

## Summary

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/java/util/TimeZone` | ` https://developer.android.com/reference/android/util/TimeUtils#getTimeZone(int,%20boolean,%20long,%20java.lang.String)(int offset, boolean dst, long when, https://developer.android.com/reference/java/lang/String country) ` Tries to return a time zone that would have had the specified offset and DST value at the specified moment in the specified country. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/util/TimeUtils#getTimeZoneDatabaseVersion()() ` Returns a String indicating the version of the time zone database currently in use. |
| ` static https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/util/TimeUtils#getTimeZoneIdsForCountryCode(java.lang.String)(https://developer.android.com/reference/java/lang/String countryCode) ` Returns time zone IDs for time zones known to be associated with a country. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/TimeUtils#isTimeBetween(java.time.LocalTime,%20java.time.LocalTime,%20java.time.LocalTime)(https://developer.android.com/reference/java/time/LocalTime reference, https://developer.android.com/reference/java/time/LocalTime start, https://developer.android.com/reference/java/time/LocalTime end) ` This method is used to find if a clock time is inclusively between two other clock times |

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

### getTimeZone

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

```
public static TimeZone getTimeZone (int offset, 
                boolean dst, 
                long when, 
                String country)
```

Tries to return a time zone that would have had the specified offset and DST value at the specified moment in the specified country. Returns null if no suitable zone could be found.

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `dst` | `boolean` <br /> |
| `when` | `long` <br /> |
| `country` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/TimeZone` | <br /> |

### getTimeZoneDatabaseVersion

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

```
public static String getTimeZoneDatabaseVersion ()
```

Returns a String indicating the version of the time zone database currently in use. The format of the string is dependent on the underlying time zone database implementation, but will typically contain the year in which the database was updated plus a letter from a to z indicating changes made within that year.

Time zone database updates should be expected to occur periodically due to political and legal changes that cannot be anticipated in advance. Therefore, when computing the time for a future event, applications should be aware that the results may differ following a time zone database update. This method allows applications to detect that a database change has occurred, and to recalculate any cached times accordingly.

The time zone database may be assumed to change only when the device runtime is restarted. Therefore, it is not necessary to re-query the database version during the lifetime of an activity.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getTimeZoneIdsForCountryCode

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

```
public static List<String> getTimeZoneIdsForCountryCode (String countryCode)
```

Returns time zone IDs for time zones known to be associated with a country.

The list returned may be different from other on-device sources like `https://developer.android.com/reference/android/icu/util/TimeZone#getRegion(java.lang.String)` as it can be curated to avoid contentious or obsolete mappings.

<br />

| Parameters ||
|---|---|
| `countryCode` | `String`: the ISO 3166-1 alpha-2 code for the country as can be obtained using `https://developer.android.com/reference/java/util/Locale#getCountry()` This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | IDs that can be passed to `https://developer.android.com/reference/java/util/TimeZone#getTimeZone(java.lang.String)` or similar methods, or `null` if the countryCode is unrecognized <br /> |

### isTimeBetween

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

```
public static boolean isTimeBetween (LocalTime reference, 
                LocalTime start, 
                LocalTime end)
```

This method is used to find if a clock time is inclusively between two other clock times

<br />

| Parameters ||
|---|---|
| `reference` | `LocalTime`: The time of the day we want check if it is between start and end. This value cannot be `null`. <br /> |
| `start` | `LocalTime`: The start time reference. This value cannot be `null`. <br /> |
| `end` | `LocalTime`: The end time. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the reference time is between the two clock times, and false otherwise. <br /> |