> For the complete documentation index, see [llms.txt](https://unitsofmeasurement.gitbook.io/unit-ri-userguide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unitsofmeasurement.gitbook.io/unit-ri-userguide/abstract-base-classes/abstract-quantity.md).

# Abstract Quantity

`AbstractQuantity` provides additional methods to convert values directly into a target unit. They are more useful as meta-data converted to the application's internal representation (typically a double primitive type in some fixed units) before computation or further processing begin. For this purpose `AbstractQuantity` provides the `longValue(Unit)` and `doubleValue(Unit)` convenience methods.

For example the `doubleValue(Unit)` method is equivalent to the following:

```
public double doubleValue(Unit<Q> unit) {
   return getUnit().getConverterTo(unit).convert(getValue().doubleValue());
}
```

With such method, user code like below are slightly easier to write:

```java
double calculateTravelTimeInSeconds(AbstractQuantity<Length> distance, AbstractQuantity<Speed> speed) {
   return distance.doubleValue(METRE) /
          speed.doubleValue(METRE_PER_SECOND);
}
```

Note that an equivalent operation can also be done using the Quantity.divide(Quantity) method.
