# Energy

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/units/Energy.kt+class:androidx.health.connect.client.units.Energy) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

*** ** * ** ***


```
class Energy : Comparable<Energy>
```

<br />

*** ** * ** ***

Represents a unit of energy. Supported units:

- calories - see `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#calories(kotlin.Double)`, `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/package-summary#(kotlin.Double).calories()`

- kilocalories - see `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#kilocalories(kotlin.Double)`, `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/package-summary#(kotlin.Double).kilocalories()`

- joules - see `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#joules(kotlin.Double)`, `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/package-summary#(kotlin.Double).joules()`

- kilojoules - see `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#kilojoules(kotlin.Double)`, `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/package-summary#(kotlin.Double).kilojoules()`

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#calories(kotlin.Double)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in calories. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#joules(kotlin.Double)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in joules. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#kilocalories(kotlin.Double)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in kilocalories. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#kilojoules(kotlin.Double)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in kilojoules. |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#compareTo(androidx.health.connect.client.units.Energy)(other: https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy)` |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#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/units/Energy#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#toString()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#inCalories()` Returns the energy in calories. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#inJoules()` Returns the energy in joules. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#inKilocalories()` Returns the energy in kilocalories. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy#inKilojoules()` Returns the energy in kilojoules. |

## Public companion functions

### calories

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

```
fun calories(value: Double): Energy
```

Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in calories.

### joules

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

```
fun joules(value: Double): Energy
```

Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in joules.

### kilocalories

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

```
fun kilocalories(value: Double): Energy
```

Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in kilocalories.

### kilojoules

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

```
fun kilojoules(value: Double): Energy
```

Creates `https://developer.android.com/reference/kotlin/androidx/health/connect/client/units/Energy` with the specified value in kilojoules.

## Public functions

### compareTo

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

```
open operator fun compareTo(other: Energy): Int
```

### equals

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

### hashCode

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

### toString

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

## Public properties

### inCalories

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

```
val inCalories: Double
```

Returns the energy in calories.

### inJoules

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

```
val inJoules: Double
```

Returns the energy in joules.

### inKilocalories

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

```
val inKilocalories: Double
```

Returns the energy in kilocalories.

### inKilojoules

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

```
val inKilojoules: Double
```

Returns the energy in kilojoules.