mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
Make QuantityType.toUnitRelative accept a String (#3802)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
parent
fb3d4e805d
commit
0d355fbbc7
@ -338,6 +338,15 @@ public class QuantityType<T extends Quantity<T>> extends Number
|
|||||||
return new QuantityType<>(result.getValue(), targetUnit);
|
return new QuantityType<>(result.getValue(), targetUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable QuantityType<T> toUnitRelative(String targetUnit) {
|
||||||
|
Unit<T> unit = (Unit<T>) AbstractUnit.parse(targetUnit);
|
||||||
|
if (unit != null) {
|
||||||
|
return toUnitRelative(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public BigDecimal toBigDecimal() {
|
public BigDecimal toBigDecimal() {
|
||||||
return new BigDecimal(quantity.getValue().toString());
|
return new BigDecimal(quantity.getValue().toString());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user