# Mass

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

*** ** * ** ***


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

<br />

*** ** * ** ***

Represents a unit of mass. Supported units:

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

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

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

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

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

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

## Summary

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#compareTo(androidx.health.connect.client.units.Mass)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Mass other)` |
| `boolean` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#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/Mass#getGrams()()` Returns the mass in grams. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#getKilograms()()` Returns the mass in kilograms. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#getMicrograms()()` Returns the mass in micrograms. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#getMilligrams()()` Returns the mass in milligrams. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#getOunces()()` Returns the mass in ounces. |
| `final double` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#getPounds()()` Returns the mass in pounds. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Mass` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#grams(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Mass` with the specified value in grams. |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#hashCode()()` |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Mass` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#kilograms(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Mass` with the specified value in kilograms. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Mass` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#micrograms(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Mass` with the specified value in micrograms. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Mass` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#milligrams(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Mass` with the specified value in milligrams. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Mass` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#ounces(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Mass` with the specified value in ounces. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Mass` | `https://developer.android.com/reference/androidx/health/connect/client/units/Mass#pounds(kotlin.Double)(double value)` Creates `https://developer.android.com/reference/androidx/health/connect/client/units/Mass` with the specified value in pounds. |
| `@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/Mass#toString()()` |

## Public methods

### compareTo

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

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

### equals

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

### getGrams

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

```
public final double getGrams()
```

Returns the mass in grams.

### getKilograms

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

```
public final double getKilograms()
```

Returns the mass in kilograms.

### getMicrograms

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

```
public final double getMicrograms()
```

Returns the mass in micrograms.

### getMilligrams

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

```
public final double getMilligrams()
```

Returns the mass in milligrams.

### getOunces

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

```
public final double getOunces()
```

Returns the mass in ounces.

### getPounds

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

```
public final double getPounds()
```

Returns the mass in pounds.

### grams

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

```
public static final @NonNull Mass grams(double value)
```

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

### hashCode

```
public int hashCode()
```

### kilograms

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

```
public static final @NonNull Mass kilograms(double value)
```

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

### micrograms

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

```
public static final @NonNull Mass micrograms(double value)
```

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

### milligrams

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

```
public static final @NonNull Mass milligrams(double value)
```

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

### ounces

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

```
public static final @NonNull Mass ounces(double value)
```

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

### pounds

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

```
public static final @NonNull Mass pounds(double value)
```

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

### toString

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