I then put the following formula in an excel cell
=DATE(A3,B3,C3)
Is there a better method?
Sun Jul 01, 2007 10:22 am
daniela
Joined: Fri Feb 03, 2006 12:23 pm Posts: 197 Location: Brasov, Romania
If you want to keep the calendar, here is a sample. You need to set also the cell data type:
-------------------------
Calendar c1 = Calendar.getInstance();
c1.setTime(date1);
int d1 = c1.get(Calendar.DAY_OF_MONTH);
int m1 = c1.get(Calendar.MONTH)+1;
int y1 = c1.get(Calendar.YEAR);
Another possible solution is to use the SimpleDateFormat for formatting your date:
---------------------------
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MM/dd/yyyy");
xlsTable.easy_getCell("A3").setValue(sdf.format(date1));
xlsTable.easy_getCell("A3").setDataType(DataType.DATE);
---------------------------
The best solution is to store the entire date (also the hours, minutes and seconds) and apply a date format for the cell:
---------------------------
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
xlsTable.easy_getCell("A3").setValue(sdf.format(date1));
xlsTable.easy_getCell("A3").setFormat("MM/dd/yyyy");
---------------------------
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum