{"id":606,"date":"2011-11-24T12:24:50","date_gmt":"2011-11-24T11:24:50","guid":{"rendered":"http:\/\/maydanoz.arved.priv.at\/blog\/?p=606"},"modified":"2017-05-24T22:21:18","modified_gmt":"2017-05-24T21:21:18","slug":"formatting_date","status":"publish","type":"post","link":"https:\/\/arved.priv.at\/weblog\/2011\/11\/24\/formatting_date\/","title":{"rendered":"Formatting Dates in JExcel"},"content":{"rendered":"<p>Jexcel has an annoying Feature: It exports Dates always as UTC.<br \/>\nThey have published some kind of workaround for reading Excelfiles, but it does not work for Writing Excel files.<br \/>\nMy workaround:<\/p>\n<pre>\nTimeZone tz = TimeZone.getDefault();\nint offset = tz.getOffset(date.getTime());\nCalendar cal = new GregorianCalendar();\ncal.setTime(date);\ncal.add(Calendar.MILLISECOND, offset);\nDateTime datetime = new DateTime(j,i, cal.getTime());\nWritableCellFormat cf = new WritableCellFormat(df);\ndatetime.setCellFormat(cf);\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Jexcel has an annoying Feature: It exports Dates always as UTC. They have published some kind of workaround for reading Excelfiles, but it does not work for Writing Excel files. My workaround: TimeZone tz = TimeZone.getDefault(); int offset = tz.getOffset(date.getTime()); Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.add(Calendar.MILLISECOND, offset); DateTime datetime = new DateTime(j,i, cal.getTime()); WritableCellFormat &hellip; <a href=\"https:\/\/arved.priv.at\/weblog\/2011\/11\/24\/formatting_date\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Formatting Dates in JExcel&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-606","post","type-post","status-publish","format-standard","hentry","category-computer-networks"],"_links":{"self":[{"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/posts\/606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/comments?post=606"}],"version-history":[{"count":1,"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":666,"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/posts\/606\/revisions\/666"}],"wp:attachment":[{"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/media?parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/categories?post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arved.priv.at\/weblog\/wp-json\/wp\/v2\/tags?post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}