Skip to content

Commit

Permalink
Fix DecimalType hex conversion example
Browse files Browse the repository at this point in the history
See: openhab/openhab-core#1526

Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn committed Jun 20, 2020
1 parent a4bf707 commit 3f6a331
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions configuration/rules-dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,16 @@ Here some other commonly needed conversions:
* For DecimalType states:

```java
//convert integer_number to string containing hex_code
var String hex_code = Long.toHexString(integer_number);
// convert integer_number to string containing hex_code
var String hex_code = Long.toHexString(integer_number)

//convert hex_code to Number type
// convert hex_code to Number type
var MyNumber = Integer.parseInt(hex_code, 16) as Number
//use the following for large_hex_code
// use the following for large_hex_code
var MyNumber = Long.parseLong(hex, 16) as Number

// coverting hex_code into DecimalType
var DecimalType parsedResult = DecimalType.valueOf(Long.parseLong(hex_code, 16).toString);
// convert hex_code to DecimalType
var DecimalType parsedResult = new DecimalType(Long.parseLong(hex_code, 16))
```

* For QuantityType states:
Expand Down

0 comments on commit 3f6a331

Please sign in to comment.