You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by lcai <la...@hotmail.com> on 2008/05/01 14:52:29 UTC
Re: How dose POI [h]:mm:ss dataformat work?
Mahesh Ganapathy wrote:
>
> 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.
>
>
Thank you for your code, but it didn't work for me... I am trying parser
[h]:mm:ss, the hours here are
longer then 24 hours, and in Java SimpleDateFormat dosen't support
[h]:mm:ss, it will roll over to 1 day.
But in POI Doc, it supports this kind of long hours dataformat. I don't know
how it works, when I gave it
the Java date object, it return me "613683:10:11"
--
View this message in context: http://www.nabble.com/How-dose-POI--h-%3Amm%3Ass-dataformat-work--tp16966115p16993234.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org