# UniversalTimeScale

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

# UniversalTimeScale

*** ** * ** ***

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

`
public

final

class
UniversalTimeScale
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

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

<br />

*** ** * ** ***

There are quite a few different conventions for binary datetime, depending on different platforms and protocols. Some of these have severe drawbacks. For example, people using Unix time (seconds since Jan 1, 1970, usually in a 32-bit integer) think that they are safe until near the year 2038. But cases can and do arise where arithmetic manipulations causes serious problems. Consider the computation of the average of two datetimes, for example: if one calculates them with`averageTime = (time1 + time2)/2`, there will be overflow even with dates beginning in 2004. Moreover, even if these problems don't occur, there is the issue of conversion back and forth between different systems.

Binary datetimes differ in a number of ways: the datatype, the unit, and the epoch (origin). We refer to these as time scales.

ICU implements a universal time scale that is similar to the .NET framework's System.DateTime. The universal time scale is a 64-bit integer that holds ticks since midnight, January 1st, 0001. (One tick is 100 nanoseconds.) Negative values are supported. This has enough range to guarantee that calculations involving dates around the present are safe.

The universal time scale always measures time according to the proleptic Gregorian calendar. That is, the Gregorian calendar's leap year rules are used for all times, even before 1582 when it was introduced. (This is different from the default ICU calendar which switches from the Julian to the Gregorian calendar in 1582. See GregorianCalendar.setGregorianChange() and ucal_setGregorianChange().) ICU provides conversion functions to and from all other major time scales, allowing datetimes in any time scale to be converted to the universal time scale, safely manipulated, and converted back to any other datetime time scale.

For more details and background, see the[Universal Time Scale](https://unicode-org.github.io/icu/userguide/datetime/universaltimescale)chapter in the ICU User Guide.

## Summary

|                                                                                                  ### Constants                                                                                                   ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [DB2_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#DB2_TIME) Used in DB2.                                                                                             |
| `int` | [DOTNET_DATE_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#DOTNET_DATE_TIME) Used in the .NET framework's`System.DateTime`structure.                                  |
| `int` | [EPOCH_OFFSET_PLUS_1_VALUE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#EPOCH_OFFSET_PLUS_1_VALUE) The constant used to select the epoch plus one value for a time scale. |
| `int` | [EPOCH_OFFSET_VALUE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#EPOCH_OFFSET_VALUE) The constant used to select the epoch offset value for a time scale.                 |
| `int` | [EXCEL_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#EXCEL_TIME) Used in Excel.                                                                                       |
| `int` | [FROM_MAX_VALUE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#FROM_MAX_VALUE) The constant used to select the maximum from value for a time scale.                         |
| `int` | [FROM_MIN_VALUE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#FROM_MIN_VALUE) The constant used to select the minimum from value for a time scale.                         |
| `int` | [ICU4C_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#ICU4C_TIME) Used in the ICU4C.                                                                                   |
| `int` | [JAVA_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#JAVA_TIME) Used in the JDK.                                                                                       |
| `int` | [MAC_OLD_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#MAC_OLD_TIME) Used in older Macintosh systems.                                                                 |
| `int` | [MAC_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#MAC_TIME) Used in the JDK.                                                                                         |
| `int` | [MAX_SCALE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#MAX_SCALE) *This constant was deprecated in API level 28. ICU 59*                                                 |
| `int` | [TO_MAX_VALUE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#TO_MAX_VALUE) The constant used to select the maximum to value for a time scale.                               |
| `int` | [TO_MIN_VALUE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#TO_MIN_VALUE) The constant used to select the minimum to value for a time scale.                               |
| `int` | [UNITS_VALUE](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#UNITS_VALUE) The constant used to select the units value for a time scale.                                      |
| `int` | [UNIX_MICROSECONDS_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#UNIX_MICROSECONDS_TIME) Data is a`long`.                                                             |
| `int` | [UNIX_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#UNIX_TIME) Used in Unix systems.                                                                                  |
| `int` | [WINDOWS_FILE_TIME](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#WINDOWS_FILE_TIME) Used in Windows for file times.                                                        |

|                                                                                                                                                                                                                     ### Public methods                                                                                                                                                                                                                      ||
|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | ` `[bigDecimalFrom](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#bigDecimalFrom(long,%20int))`(long otherTime, int timeScale) ` Convert a`long`datetime from the given time scale to the universal time scale.                                                                                                                  |
| ` static `[BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | ` `[bigDecimalFrom](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#bigDecimalFrom(double,%20int))`(double otherTime, int timeScale) ` Convert a`double`datetime from the given time scale to the universal time scale.                                                                                                            |
| ` static `[BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | ` `[bigDecimalFrom](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#bigDecimalFrom(android.icu.math.BigDecimal,%20int))`(`[BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal)` otherTime, int timeScale) ` Convert a`BigDecimal`datetime from the given time scale to the universal time scale.      |
| ` static long`                                                                              | ` `[from](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#from(long,%20int))`(long otherTime, int timeScale) ` Convert a`long`datetime from the given time scale to the universal time scale.                                                                                                                                      |
| ` static long`                                                                              | ` `[getTimeScaleValue](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#getTimeScaleValue(int,%20int))`(int scale, int value) ` Get a value associated with a particular time scale.                                                                                                                                                |
| ` static `[BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | ` `[toBigDecimal](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#toBigDecimal(long,%20int))`(long universalTime, int timeScale) ` Convert a datetime from the universal time scale to a`BigDecimal`in the given time scale.                                                                                                       |
| ` static `[BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | ` `[toBigDecimal](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#toBigDecimal(android.icu.math.BigDecimal,%20int))`(`[BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal)` universalTime, int timeScale) ` Convert a datetime from the universal time scale to a`BigDecimal`in the given time scale. |
| ` static long`                                                                              | ` `[toLong](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#toLong(long,%20int))`(long universalTime, int timeScale) ` Convert a datetime from the universal time scale stored as a`BigDecimal`to a`long`in the given time scale.                                                                                                  |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Constants

### DB2_TIME

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

```
public static final int DB2_TIME
```

Used in DB2. Data is a`?unknown?`. Value is days since December 31, 1899.

<br />

Constant Value: 8 (0x00000008)  

### DOTNET_DATE_TIME

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

```
public static final int DOTNET_DATE_TIME
```

Used in the .NET framework's`System.DateTime`structure. Data is a`long`. Value is ticks (1 tick == 100 nanoseconds) since January 1, 0001.

<br />

Constant Value: 4 (0x00000004)  

### EPOCH_OFFSET_PLUS_1_VALUE

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

```
public static final int EPOCH_OFFSET_PLUS_1_VALUE
```

The constant used to select the epoch plus one value for a time scale. NOTE: This is an internal value. DO NOT USE IT. May not actually be equal to the epoch offset value plus one.

<br />

**See also:**

- [getTimeScaleValue(int, int)](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#getTimeScaleValue(int,%20int))

Constant Value: 6 (0x00000006)  

### EPOCH_OFFSET_VALUE

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

```
public static final int EPOCH_OFFSET_VALUE
```

The constant used to select the epoch offset value for a time scale.

<br />

**See also:**

- [getTimeScaleValue(int, int)](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#getTimeScaleValue(int,%20int))

Constant Value: 1 (0x00000001)  

### EXCEL_TIME

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

```
public static final int EXCEL_TIME
```

Used in Excel. Data is a`?unknown?`. Value is days since December 31, 1899.

<br />

Constant Value: 7 (0x00000007)  

### FROM_MAX_VALUE

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

```
public static final int FROM_MAX_VALUE
```

The constant used to select the maximum from value for a time scale.

<br />

**See also:**

- [getTimeScaleValue(int, int)](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#getTimeScaleValue(int,%20int))

Constant Value: 3 (0x00000003)  

### FROM_MIN_VALUE

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

```
public static final int FROM_MIN_VALUE
```

The constant used to select the minimum from value for a time scale.

<br />

**See also:**

- [getTimeScaleValue(int, int)](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#getTimeScaleValue(int,%20int))

Constant Value: 2 (0x00000002)  

### ICU4C_TIME

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

```
public static final int ICU4C_TIME
```

Used in the ICU4C. Data is a`double`. Value is milliseconds since January 1, 1970.

<br />

Constant Value: 2 (0x00000002)  

### JAVA_TIME

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

```
public static final int JAVA_TIME
```

Used in the JDK. Data is a`long`. Value is milliseconds since January 1, 1970.

<br />

Constant Value: 0 (0x00000000)  

### MAC_OLD_TIME

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

```
public static final int MAC_OLD_TIME
```

Used in older Macintosh systems. Data is an`int`. Value is seconds since January 1, 1904.

<br />

Constant Value: 5 (0x00000005)  

### MAC_TIME

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

```
public static final int MAC_TIME
```

Used in the JDK. Data is a`double`. Value is milliseconds since January 1, 2001.

<br />

Constant Value: 6 (0x00000006)  

### MAX_SCALE

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

```
public static final int MAX_SCALE
```

<br />

**This constant was deprecated in API level 28.**   
ICU 59

This is the first unused time scale value.

<br />

Constant Value: 10 (0x0000000a)  

### TO_MAX_VALUE

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

```
public static final int TO_MAX_VALUE
```

The constant used to select the maximum to value for a time scale.

<br />

**See also:**

- [getTimeScaleValue(int, int)](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#getTimeScaleValue(int,%20int))

Constant Value: 5 (0x00000005)  

### TO_MIN_VALUE

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

```
public static final int TO_MIN_VALUE
```

The constant used to select the minimum to value for a time scale.

<br />

**See also:**

- [getTimeScaleValue(int, int)](https://developer.android.com/reference/android/icu/util/UniversalTimeScale#getTimeScaleValue(int,%20int))

Constant Value: 4 (0x00000004)  

### UNITS_VALUE

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

```
public static final int UNITS_VALUE
```

The constant used to select the units value for a time scale.

<br />

Constant Value: 0 (0x00000000)  

### UNIX_MICROSECONDS_TIME

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

```
public static final int UNIX_MICROSECONDS_TIME
```

Data is a`long`. Value is microseconds since January 1, 1970. Similar to Unix time (linear value from 1970) and struct timeval (microseconds resolution).

<br />

Constant Value: 9 (0x00000009)  

### UNIX_TIME

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

```
public static final int UNIX_TIME
```

Used in Unix systems. Data is an`int`or a`long`. Value is seconds since January 1, 1970.

<br />

Constant Value: 1 (0x00000001)  

### WINDOWS_FILE_TIME

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

```
public static final int WINDOWS_FILE_TIME
```

Used in Windows for file times. Data is a`long`. Value is ticks (1 tick == 100 nanoseconds) since January 1, 1601.

<br />

Constant Value: 3 (0x00000003)

## Public methods

### bigDecimalFrom

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

```
public static BigDecimal bigDecimalFrom (long otherTime, 
                int timeScale)
```

Convert a`long`datetime from the given time scale to the universal time scale. All calculations are done using`BigDecimal`to guarantee that the value does not go out of range.

<br />

|                        Parameters                         ||
|-------------|----------------------------------------------|
| `otherTime` | `long`: The`long`datetime <br />             |
| `timeScale` | `int`: The time scale to convert from <br /> |

|                                                                   Returns                                                                    ||
|-----------------------------------------------------------------------------------|-----------------------------------------------------------|
| [BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | The datetime converted to the universal time scale <br /> |

### bigDecimalFrom

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

```
public static BigDecimal bigDecimalFrom (double otherTime, 
                int timeScale)
```

Convert a`double`datetime from the given time scale to the universal time scale. All calculations are done using`BigDecimal`to guarantee that the value does not go out of range.

<br />

|                        Parameters                         ||
|-------------|----------------------------------------------|
| `otherTime` | `double`: The`double`datetime <br />         |
| `timeScale` | `int`: The time scale to convert from <br /> |

|                                                                   Returns                                                                    ||
|-----------------------------------------------------------------------------------|-----------------------------------------------------------|
| [BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | The datetime converted to the universal time scale <br /> |

### bigDecimalFrom

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

```
public static BigDecimal bigDecimalFrom (BigDecimal otherTime, 
                int timeScale)
```

Convert a`BigDecimal`datetime from the given time scale to the universal time scale. All calculations are done using`BigDecimal`to guarantee that the value does not go out of range.

<br />

|                        Parameters                         ||
|-------------|----------------------------------------------|
| `otherTime` | `BigDecimal`: The`BigDecimal`datetime <br /> |
| `timeScale` | `int`: The time scale to convert from <br /> |

|                                                                   Returns                                                                    ||
|-----------------------------------------------------------------------------------|-----------------------------------------------------------|
| [BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | The datetime converted to the universal time scale <br /> |

### from

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

```
public static long from (long otherTime, 
                int timeScale)
```

Convert a`long`datetime from the given time scale to the universal time scale.

<br />

|                        Parameters                         ||
|-------------|----------------------------------------------|
| `otherTime` | `long`: The`long`datetime <br />             |
| `timeScale` | `int`: The time scale to convert from <br /> |

|                              Returns                              ||
|--------|-----------------------------------------------------------|
| `long` | The datetime converted to the universal time scale <br /> |

### getTimeScaleValue

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

```
public static long getTimeScaleValue (int scale, 
                int value)
```

Get a value associated with a particular time scale.

<br />

|                            Parameters                             ||
|---------|----------------------------------------------------------|
| `scale` | `int`: - the time scale <br />                           |
| `value` | `int`: - a constant representing the value to get <br /> |

|           Returns           ||
|--------|---------------------|
| `long` | - the value. <br /> |

### toBigDecimal

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

```
public static BigDecimal toBigDecimal (long universalTime, 
                int timeScale)
```

Convert a datetime from the universal time scale to a`BigDecimal`in the given time scale.

<br />

|                                Parameters                                ||
|-----------------|---------------------------------------------------------|
| `universalTime` | `long`: The datetime in the universal time scale <br /> |
| `timeScale`     | `int`: The time scale to convert to <br />              |

|                                                                 Returns                                                                  ||
|-----------------------------------------------------------------------------------|-------------------------------------------------------|
| [BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | The datetime converted to the given time scale <br /> |

### toBigDecimal

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

```
public static BigDecimal toBigDecimal (BigDecimal universalTime, 
                int timeScale)
```

Convert a datetime from the universal time scale to a`BigDecimal`in the given time scale.

<br />

|                                   Parameters                                   ||
|-----------------|---------------------------------------------------------------|
| `universalTime` | `BigDecimal`: The datetime in the universal time scale <br /> |
| `timeScale`     | `int`: The time scale to convert to <br />                    |

|                                                                 Returns                                                                  ||
|-----------------------------------------------------------------------------------|-------------------------------------------------------|
| [BigDecimal](https://developer.android.com/reference/android/icu/math/BigDecimal) | The datetime converted to the given time scale <br /> |

### toLong

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

```
public static long toLong (long universalTime, 
                int timeScale)
```

Convert a datetime from the universal time scale stored as a`BigDecimal`to a`long`in the given time scale. Since this calculation requires a divide, we must round. The straight forward way to round by adding half of the divisor will push the sum out of range for values within have the divisor of the limits of the precision of a`long`. To get around this, we do the rounding like this:

`
(universalTime - units + units/2) / units + 1
`

(i.e. we subtract units first to guarantee that we'll still be in range when we add`units/2`. We then need to add one to the quotent to make up for the extra subtraction. This simplifies to:

`
(universalTime - units/2) / units - 1
`

For negative values to round away from zero, we need to flip the signs:

`
(universalTime + units/2) / units + 1
`

Since we also need to subtract the epochOffset, we fold the`+/- 1`into the offset value. (i.e.`epochOffsetP1`,`epochOffsetM1`.)

<br />

|                                Parameters                                ||
|-----------------|---------------------------------------------------------|
| `universalTime` | `long`: The datetime in the universal time scale <br /> |
| `timeScale`     | `int`: The time scale to convert to <br />              |

|                            Returns                            ||
|--------|-------------------------------------------------------|
| `long` | The datetime converted to the given time scale <br /> |