What's the best way to get the difference between ...
# getting-started
a
What's the best way to get the difference between two date times (time in 24hr format)?
s
I like using the Kotlinx datetime library
👍 1
c
As an example, between March 31st 2024, 01:00 and April 1st 2024, 01:00, in France, there are only 23 hours. Without knowing which country the user is in, you can't answer the question. And that's only daylight saving issues.
👍 1
a
Yeah, I learned about that channel after posting here.
r
If you exceptionally and completely do not care about time zones you can use
java.time
classes:
Copy code
Duration.between(LocalDateTime.parse("2007-12-03T10:15:30"), LocalDateTime.parse("2007-12-03T10:15:30"))
👍 1