Bug 48389 - DateUtil.isADateFormat Replaces Characters Incorrectly
Summary: DateUtil.isADateFormat Replaces Characters Incorrectly
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.5-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2009-12-14 14:34 UTC by Chris Barlock
Modified: 2009-12-28 03:57 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Chris Barlock 2009-12-14 14:34:06 UTC
I have an Excel 2003 spreadsheet in which a cell has the custom date format:


DateUtil.isaDateFormat trashes this by converting the '\T' to '.'  The problem is this line of code:

        // And \. into .
        fs = fs.replaceAll("\\\\.",".");

It should be:

        fs = fs.replaceAll("\\\\\\.",".");

The regex parser sees the former as '\\.' which it interprets as backslash followed by any character.  The regex parser sees the latter as '\\\.' which it reads as backslash followed by period -- which is what the code wanted to do.
Comment 1 Yegor Kozlov 2009-12-28 03:57:14 UTC
The problem was fixed in r893105 which was committed on Dec 22. 
See https://issues.apache.org/bugzilla/show_bug.cgi?id=48425

consecutive regexp replacements were replaced by a simple loop collecting characters into a buffer. This refactoring also solved the issue with "\."