Determine Whether Daylight Savings Time (DST) is Active in Java for a Specified Date

This is the answer for the machine on which the question is being asked: TimeZone.getDefault().inDaylightTime( new Date() ); A server trying to figure this out for a client will need the client’s time zone. See @Powerlord answer for the reason why. For any particular TimeZone TimeZone.getTimeZone( “US/Alaska”).inDaylightTime( new Date() );

Best practices with saving datetime & timezone info in database when data is dependant on datetime

Hugo’s answer is mostly correct, but I’ll add a few key points: When you’re storing the customer’s time zone, do NOT store a numerical offset. As others have pointed out, the offset from UTC is only for a single point in time, and can easily change for DST and for other reasons. Instead, you should … Read more

Is it always a good idea to store time in UTC or is this the case where storing in local time is better?

I think that in order to answer that question, we should think about the benefits of using UTC to store timestamps. I personally think that the main benefit to that is that the time is always (mostly) guaranteed to be consistent. In other words, whenever the timezone is changed, or DST applied, you don’t get … Read more

Does UTC observe daylight saving time?

No, UTC itself never has DST. It is the constant frame of reference other time zones are expressed relative to. From the Wikipedia UTC page: UTC does not change with a change of seasons, but local time or civil time may change if a time zone jurisdiction observes daylight saving time or summer time. For … Read more

MySQL datetime fields and daylight savings time — how do I reference the “extra” hour?

I’ve got it figured out for my purposes. I’ll summarize what I learned (sorry, these notes are verbose; they’re as much for my future referral as anything else). Contrary to what I said in one of my previous comments, DATETIME and TIMESTAMP fields do behave differently. TIMESTAMP fields (as the docs indicate) take whatever you … Read more

How to check if DST (Daylight Saving Time) is in effect, and if so, the offset?

This code uses the fact that getTimezoneOffset returns a greater value during Standard Time versus Daylight Saving Time (DST). Thus it determines the expected output during Standard Time, and it compares whether the output of the given date the same (Standard) or less (DST). Note that getTimezoneOffset returns positive numbers of minutes for zones west … Read more