Skip to content
Advertisement

how to handle date comparison in Java during daylight saving?

Not to run code at 5:30 Morning in Summer and not to run code on 6:30 in winter.

In Java Code, Applied following

JavaScript

but now winter comes and we need not not run it at 6:30 AM

How to handle this use case for daylight saving areas?

Advertisement

Answer

You can use TimeZone‘s inDaylightTime() method to determine if day light saving is applied or not e.g.

JavaScript

For machine’s default time zone, you can check like

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement