# Pb with Integer::parseInt in a rule

**URL:** <https://community.openhab.org/t/pb-with-integer-parseint-in-a-rule/2551>\
**Category:** Scripts & Rules\
**Created:** [September 14, 2015, 10:27am UTC](https://community.openhab.org/t/pb-with-integer-parseint-in-a-rule/2551 "2015-09-14T10:27:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilles](https://community.openhab.org/letter_avatar_proxy/v4/letter/g/ce7236/32.png) [@gilles](https://community.openhab.org/u/gilles)\
**Post date:** [September 14, 2015, 10:27am UTC](https://community.openhab.org/t/pb-with-integer-parseint-in-a-rule/2551/1 "2015-09-14T10:27:55Z")

</div>

Hi,

I just want to get the integer part of a decimal number. Here is what I want to do with my test rule.

import java.lang.Math  
import java.lang.Integer

var Number Display\_Hour\_Time

var Number Test

rule “Test”  
when  
Item Switch\_test received command  
then  
Test = 19.82  
Display\_Hour\_Time = (Integer::parseInt(Test))  
sendXMPP(“xxxxxx@xxxxxxxx”,"Test: "+ Display\_Hour\_Time)  
end

I get an exception like: Could not invoke method: java.lang.Integer.parseInt(java.lang.String,int) on instance: null

I search on the web and don’t find anything. Someone know what to do ?

Thank you,

Gilles.

---

<div class="post-metadata">

**Author:** ![danielwalters86](https://community.openhab.org/user_avatar/community.openhab.org/danielwalters86/32/37745_2.png) [@danielwalters86](https://community.openhab.org/u/danielwalters86)\
**Post date:** [September 15, 2015, 7:35pm UTC](https://community.openhab.org/t/pb-with-integer-parseint-in-a-rule/2551/2 "2015-09-15T19:35:57Z")

</div>

Whilst I don’t know how to do what you want off the top of my head, I suspect the error is because parseInt expects you to pass it a string.

---

<div class="post-metadata">

**Author:** ![gilles](https://community.openhab.org/letter_avatar_proxy/v4/letter/g/ce7236/32.png) [@gilles](https://community.openhab.org/u/gilles)\
**Post date:** [October 11, 2015, 5:11pm UTC](https://community.openhab.org/t/pb-with-integer-parseint-in-a-rule/2551/3 "2015-10-11T17:11:28Z")

</div>

Hi Daniel,

Really sorry for my late answer.

I just want to convert a decimal time in “normal time”. like this:

19,5 =\> 19h30 min.

the decimal time is stored in an item.
