Split Decimal instead round

i want to split the decimal after one comma instead rounding values.

i use follow rule script:

//watt = 1567
val watt = (triggeringItem.state as Number)/1000
//watt = 1.567000000
val String MajorWatt = watt.toString().split(".").get(0)
val String MinorWatt = watt.toString().split(".").get(1)
// val CompleteWatt = MajorWatt + “.” + MinorWatt.substring(0,1)
// watt should be 1.5

but i get follow error message:

==> /var/log/openhab2/openhab.log <==
2018-03-15 19:04:23.172 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'PowerStripWatt': 0

anybody can help me to solve this?

i dont want to round the second number. it should only cut to the first number after comma (or dot here)

Verify that watt actually is 1.567 and not 1 or 2. In Java, the underlying environment upon which the Rules DSL runs, when you divide using integer values the result is an integer. That might be happening here.

I don’t think that would be the case but it could be.

But, since it looks like you are trying to round the value to one decimal place, please see my reply on the other thread about using [%.1f] in labels and String::format for logging to round floating point numbers for display.