This how you can do it

DateFormat df = *new* SimpleDateFormat("yyyy/MM");
HSSFCell formatCell = valueRow.createCell((*short*) 0);
*try*
{
   formatCell.setCellValue(df.parse(period));
   formatCell.setCellStyle(m_dateStyle);
}

where m_dateStyle is defined as

m_dateStyle = m_workbook.createCellStyle();
m_dateStyle.setAlignment(HSSFCellStyle.*ALIGN_LEFT*);
m_dateStyle.setVerticalAlignment(HSSFCellStyle.*VERTICAL_CENTER*);
m_dateStyle.setDataFormat(HSSFDataFormat.*getBuiltinFormat*("mmm-yy"));

Make sure that the SimpleDateFormat and the getBuiltinFormat (line above)
match in the format you specify.

Reply via email to