You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Miroslav Šulc <mi...@startnet.cz> on 2007/08/04 21:40:18 UTC

how to use isADateFormat()

Hi,

I tried to figure out how to use HSSFDateUtil.isADateFormat() but didn't
find any info. What is not obvious to me is where should I get the
values for parameters of the method.

Also I would expect HSSFDateUtil.isCellDateFormatted() would now call
HSSFDateUtil.isADateFormat() but it doesn't and it still checks only
internal formats.

Also I'm not sure whether it is a purpose or just omission but
isADateFormat() will return false on datetime formats and maybe even on
time formats (I didn't check this yet).

--
Miroslav Šulc


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: how to use isADateFormat()

Posted by Nick Burch <ni...@torchbox.com>.
On Sat, 4 Aug 2007, Miroslav ?ulc wrote:
> I tried to figure out how to use HSSFDateUtil.isADateFormat() but didn't 
> find any info. What is not obvious to me is where should I get the 
> values for parameters of the method.

The format index is just like isInternalDateFormat takes, which you can 
get from a HSSFStyle. The format string was a bit trickier to get at, so 
I've updated HSSFStyle to also return that (via getDataFormatString)

> Also I would expect HSSFDateUtil.isCellDateFormatted() would now call 
> HSSFDateUtil.isADateFormat() but it doesn't and it still checks only 
> internal formats.

That was an oversight - isADateFormat is quite a new addition to the 
codebase. I've updated isCellDateFormatted to call this instead

> Also I'm not sure whether it is a purpose or just omission but 
> isADateFormat() will return false on datetime formats and maybe even on 
> time formats (I didn't check this yet).

I'm not sure that it should return true on pure time formats, since 
they don't nicely match onto a java date object.

Haven't tried with a datetime. If it isn't playing nicely, you could try 
adding some examples to
 	src/testcases/org/apache/poi/hssf/data/DateFormats.xls
and uploading a new version to bugzilla. We can then update 
TestHSSFDateUtil to check that these get correctly handled, and tweak the 
HSSFDateUtil code as required

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: how to use isADateFormat()

Posted by Miroslav Šulc <mi...@startnet.cz>.
One more idea. The more I think about it, the more it makes sense to me
to implement isADateFormat() directly on FormatRecord instead of digging
out (that's the problem I am facing, I do not know how to dig the values
out when using HSSFWorkbook) the values from FormatRecord and
transporting them to HSSFDateUtil. I think putting that method in
FormatRecord would be a better design and also easier to use.

--
Miroslav Šulc


Miroslav Šulc napsal(a):
> Hi,
>
> I tried to figure out how to use HSSFDateUtil.isADateFormat() but didn't
> find any info. What is not obvious to me is where should I get the
> values for parameters of the method.
>
> Also I would expect HSSFDateUtil.isCellDateFormatted() would now call
> HSSFDateUtil.isADateFormat() but it doesn't and it still checks only
> internal formats.
>
> Also I'm not sure whether it is a purpose or just omission but
> isADateFormat() will return false on datetime formats and maybe even on
> time formats (I didn't check this yet).
>
> --
> Miroslav Šulc

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org