I receive this Date Time pattern from Server as a string.
Sa. 07.01.2023 16:39:15
Now i want to check if 1 minute is over. Like if the gap between the current time and the time (received as a string) from server is longer than a minute.
The time zone is in Europe. Like Austria.
LocalDateTime
.LocalDateTime
into aZonedDateTime
by applying aZoneId
.ZonedDateTime
in the appliedZoneId
.ZonedDateTime
and theZonedDateTime
obtained from the date-time string.Demo:
Output from a sample run:
ONLINE DEMO
Learn more about the modern Date-Time API from Trail: Date Time.
Incorporating the following valuable alternative solution suggested by Basil Bourque:
ONLINE DEMO