Stephan van Hulst wrote:Your post does not make sense to me. Are you saying that you don't care about the exact difference in time? The difference in time depends on the date, time and time zone. If you care about the exact difference, you should care about time zone rules.
Stephan van Hulst wrote:What Dave means is, what do you intend your application to do when the user has selected a time zone that uses daylight saving time, and has selected a time that is either invalid for the date the clock is adjusted, or ambiguous?
For instance, if the user has selected 2:30 AM as the time to perform the task, in the timezone Europe/Amsterdam, what do you expect your application to do on October 29th 2017? And on March 25th 2018? Will the task be performed twice? Will it be performed at all? Will the application crash?
Stephan van Hulst wrote:Your code is not correct. The application time consists of the wrong date if LocalDate.now() is a different date than the date of the current day in the entered time zone. You need to use the current date of the time zone.
You don't need to jump over difficult hurdles to get the current time. Just use Instant.now().
Dave Tolls wrote:I notice in your example you are using GMT.
What happens between the end of March and the end of October each year?
Is the user going to be OK with whatever it is running an hour later than they had specified?