Hello all,
I have a strange issue with formatting dates. My current code set is this:
int dateNumber = this.getDateFormat(dcQuestion.getDateFormat());
theCell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cs.setDataFormat((short)dateNumber);
theCell.setCellStyle(cs);
SimpleDateFormat dateFormatter = new
SimpleDateFormat(dcQuestion.getDateFormat());
theCell.setCellValue(dateFormatter.parse(dcQuestion.getCurrentValue()));
it produces this:
visitDateEnrollment
4/15/2002
1/0/1900
1/0/1900
1/0/1900
1/0/1900
1/0/1900
and if I try this:
if(!dcQuestion.getCurrentValue().equals("")){
theCell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cs.setDataFormat((short)this.getDateFormat(dcQuestion.getDateFormat()));
theCell.setCellStyle(cs);
SimpleDateFormat dateFormatter = new
SimpleDateFormat(dcQuestion.getDateFormat());
theCell.setCellValue(dateFormatter.parse(dcQuestion.getCurrentValue()));
}else{
theCell.setCellType(HSSFCell.CELL_TYPE_STRING);
cs.setDataFormat((short)0); //"General"
theCell.setCellValue("");
}
I get this:
37,361.00
<empty>
<empty>
<empty>
<empty>
<empty>
I would ideally like to be able to have both the date format and the <empty>
cells but as you can see when I try to use both I get the strange output for
valid dates.
Anyone got any ideas as to what could cause this?
thanks,
-Jared
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>