November 2011 Archives

Formatting Dates in JExcel

| | Comments (0) | TrackBacks (0)

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 cf = new WritableCellFormat(df);
datetime.setCellFormat(cf);

About this Archive

This page is an archive of entries from November 2011 listed from newest to oldest.

October 2011 is the previous archive.

February 2012 is the next archive.

Find recent content on the main index or look in the archives to find all content.