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

*** ** * ** ***


```
public final class Energy implements Comparable<@NonNull Energy>
```

<br />

*** ** * ** ***

Represents a unit of energy. Supported units:

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

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

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

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

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#calories(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Energy` with the specified value in calories. |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#compareTo(androidx.health.connect.client.units.Energy)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Energy other)` |
| `boolean` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#getCalories()()` Returns the energy in calories. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#getJoules()()` Returns the energy in joules. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#getKilocalories()()` Returns the energy in kilocalories. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#getKilojoules()()` Returns the energy in kilojoules. |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#hashCode()()` |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#joules(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Energy` with the specified value in joules. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#kilocalories(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Energy` with the specified value in kilocalories. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Energy` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#kilojoules(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Energy` with the specified value in kilojoules. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/health/connect/client/units/Energy#toString()()` |

## Public methods

### calories

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

```
public static final @NonNull Energy calories(double value)
```

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

### compareTo

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

```
public int compareTo(@NonNull Energy other)
```

### equals

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

### getCalories

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

```
public final double getCalories()
```

Returns the energy in calories.

### getJoules

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

```
public final double getJoules()
```

Returns the energy in joules.

### getKilocalories

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

```
public final double getKilocalories()
```

Returns the energy in kilocalories.

### getKilojoules

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

```
public final double getKilojoules()
```

Returns the energy in kilojoules.

### hashCode

```
public int hashCode()
```

### joules

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

```
public static final @NonNull Energy joules(double value)
```

Creates `https://developer.android.com/reference/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)

```
public static final @NonNull Energy kilocalories(double value)
```

Creates `https://developer.android.com/reference/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)

```
public static final @NonNull Energy kilojoules(double value)
```

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

### toString

```
public @NonNull String toString()
```