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);

0 TrackBacks

Listed below are links to blogs that reference this entry: Formatting Dates in JExcel.

TrackBack URL for this entry: http://arved.priv.at/cgi-bin/mt/mt-tb.cgi/557

Leave a comment

About this Entry

This page contains a single entry by arved published on November 24, 2011 12:24 PM.

Useful Thunderbird Addons was the previous entry in this blog.

annoying things in GIT is the next entry in this blog.

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