{"id":36,"date":"2003-11-18T11:39:59","date_gmt":"2003-11-18T01:39:59","guid":{"rendered":"http:\/\/www.thunderguy.com\/plusplus\/20050422\/java-versus-daylight-savings-time\/"},"modified":"2005-06-30T22:28:09","modified_gmt":"2005-06-30T12:28:09","slug":"java-versus-daylight-savings-time","status":"publish","type":"post","link":"https:\/\/thunderguy.com\/semicolon\/2003\/11\/18\/java-versus-daylight-savings-time\/","title":{"rendered":"Java versus Daylight savings time"},"content":{"rendered":"<p>Depending on the version of the Java runtime and the location of the host, the Java <code>Date<\/code> and <code>Calendar<\/code> routines may take daylight savings time into account. For example:<\/p>\n<ul>\n<li>If you set a <code>Calendar<\/code> or <code>Date<\/code> to a specific value and then read it back, you may end up with a time later than the one you set. (You could even conceivably end up with an earlier time if you set it a millisecond before daylight savings time ends, and then read it back after.)<\/li>\n<li>If you add a duration to a date, you may end up with a date earlier or later than you expect. You may even end up with exactly the same date, or one even earlier than what you started with. Similar surprises may occur when you subtract duration from a date.<\/li>\n<\/ul>\n<p>This can be dangerous in time-based loops that expect each time to be strictly greater than the previous time. Without care, infinite loops can result.<\/p>\n<p>Also remember that results are usually dependent on  the default time zone. So even if the program works for you, it may fail mysteriously at the deployment site in <a href=\"http:\/\/www.allsiberia.com\/novosibirsk\/\">Novosibirsk<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Depending on the version of the Java runtime and the location of the host, the Java Date and Calendar routines may take daylight savings time into account. For example: If you set a Calendar or Date to a specific value and then read it back, you may end up with a time later than the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[4],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","tag-java"],"_links":{"self":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":0,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"wp:attachment":[{"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thunderguy.com\/semicolon\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}