mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-26 20:21:33 +01:00
the format pattern must not be null (#874)
Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
This commit is contained in:
parent
024cc5d40e
commit
0fc38a910b
@ -229,12 +229,14 @@ public class QuantityType<T extends Quantity<T>> extends Number
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(@Nullable String pattern) {
|
public String format(String pattern) {
|
||||||
String formatPattern = pattern;
|
final String formatPattern;
|
||||||
|
|
||||||
if (formatPattern != null && formatPattern.contains(UnitUtils.UNIT_PLACEHOLDER)) {
|
if (pattern.contains(UnitUtils.UNIT_PLACEHOLDER)) {
|
||||||
String unitSymbol = getUnit().equals(SmartHomeUnits.PERCENT) ? "%%" : getUnit().toString();
|
String unitSymbol = getUnit().equals(SmartHomeUnits.PERCENT) ? "%%" : getUnit().toString();
|
||||||
formatPattern = formatPattern.replace(UnitUtils.UNIT_PLACEHOLDER, unitSymbol);
|
formatPattern = pattern.replace(UnitUtils.UNIT_PLACEHOLDER, unitSymbol);
|
||||||
|
} else {
|
||||||
|
formatPattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The value could be an integer value. Try to convert to BigInteger in
|
// The value could be an integer value. Try to convert to BigInteger in
|
||||||
|
Loading…
Reference in New Issue
Block a user