[Solved] Time calculations

Tags: #<Tag:0x00007fadfc456bc0>

(Vinny Mautone) #1

Hello to everyone, I am new to the world of openhab, and java, I was studying python then I discovered openhab, I would need help for a small project I’m realizing, from the astro binding of openhab2 there are various things but I would need to calculate the duration from dawn to noon, you can help me thank you.

P.S. this is an on-line translation

(Vinny Mautone) #2
val Number step = ((AstroSunData_Noon_StartTime.state as DateTimeType).calendar.timeInMillis) - ((AstroSunData_Sunrise.state as DateTimeType).calendar.timeInMillis)

( ) #3

Hey Vinny and welcome to our community!

Before going into details I’d like to point you to a few existing topics that I believe include the solution to your question and will teach you a few things on the way.

Let us know how far you got with that :wink:

Edit: Your solution already looks good, you’ll just have to convert milliseconds to something meaningful.