Fix bug #45087 - Correctly detect date formats like [Black]YYYY as being date based
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@660889 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
81f384dabf
commit
50d81039da
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
<!-- Don't forget to update status.xml too! -->
|
<!-- Don't forget to update status.xml too! -->
|
||||||
<release version="3.1-final" date="2008-06-??">
|
<release version="3.1-final" date="2008-06-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">45087 - Correctly detect date formats like [Black]YYYY as being date based</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">45060 - Improved token class transformation during formula parsing</action>
|
<action dev="POI-DEVELOPERS" type="add">45060 - Improved token class transformation during formula parsing</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">44840 - Improved handling of HSSFObjectData, especially for entries with data held not in POIFS</action>
|
<action dev="POI-DEVELOPERS" type="add">44840 - Improved handling of HSSFObjectData, especially for entries with data held not in POIFS</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">45043 - Support for getting excel cell comments when extracting text</action>
|
<action dev="POI-DEVELOPERS" type="add">45043 - Support for getting excel cell comments when extracting text</action>
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<!-- Don't forget to update changes.xml too! -->
|
<!-- Don't forget to update changes.xml too! -->
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.1-final" date="2008-06-??">
|
<release version="3.1-final" date="2008-06-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">45087 - Correctly detect date formats like [Black]YYYY as being date based</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">45060 - Improved token class transformation during formula parsing</action>
|
<action dev="POI-DEVELOPERS" type="add">45060 - Improved token class transformation during formula parsing</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">44840 - Improved handling of HSSFObjectData, especially for entries with data held not in POIFS</action>
|
<action dev="POI-DEVELOPERS" type="add">44840 - Improved handling of HSSFObjectData, especially for entries with data held not in POIFS</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">45043 - Support for getting excel cell comments when extracting text</action>
|
<action dev="POI-DEVELOPERS" type="add">45043 - Support for getting excel cell comments when extracting text</action>
|
||||||
|
@ -220,9 +220,13 @@ public class HSSFDateUtil
|
|||||||
// switching stuff, which we can ignore
|
// switching stuff, which we can ignore
|
||||||
fs = fs.replaceAll(";@", "");
|
fs = fs.replaceAll(";@", "");
|
||||||
|
|
||||||
// If it starts with [$-...], then it is a date, but
|
// If it starts with [$-...], then could be a date, but
|
||||||
// who knows what that starting bit is all about
|
// who knows what that starting bit is all about
|
||||||
fs = fs.replaceAll("\\[\\$\\-.*?\\]", "");
|
fs = fs.replaceAll("^\\[\\$\\-.*?\\]", "");
|
||||||
|
|
||||||
|
// If it starts with something like [Black] or [Yellow],
|
||||||
|
// then it could be a date
|
||||||
|
fs = fs.replaceAll("^\\[[a-zA-Z]+\\]", "");
|
||||||
|
|
||||||
// Otherwise, check it's only made up, in any case, of:
|
// Otherwise, check it's only made up, in any case, of:
|
||||||
// y m d h s - / , . :
|
// y m d h s - / , . :
|
||||||
|
@ -257,9 +257,15 @@ public class TestHSSFDateUtil extends TestCase {
|
|||||||
// (who knows what they mean though...)
|
// (who knows what they mean though...)
|
||||||
"[$-F800]dddd\\,\\ mmm\\ dd\\,\\ yyyy",
|
"[$-F800]dddd\\,\\ mmm\\ dd\\,\\ yyyy",
|
||||||
"[$-F900]ddd/mm/yyy",
|
"[$-F900]ddd/mm/yyy",
|
||||||
|
// These ones specify colours, who knew that was allowed?
|
||||||
|
"[BLACK]dddd/mm/yy",
|
||||||
|
"[yeLLow]yyyy-mm-dd"
|
||||||
};
|
};
|
||||||
for(int i=0; i<formats.length; i++) {
|
for(int i=0; i<formats.length; i++) {
|
||||||
assertTrue( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
|
assertTrue(
|
||||||
|
formats[i] + " is a date format",
|
||||||
|
HSSFDateUtil.isADateFormat(formatId, formats[i])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then time based ones too
|
// Then time based ones too
|
||||||
@ -270,7 +276,10 @@ public class TestHSSFDateUtil extends TestCase {
|
|||||||
"mm/dd HH:MM PM", "mm/dd HH:MM pm"
|
"mm/dd HH:MM PM", "mm/dd HH:MM pm"
|
||||||
};
|
};
|
||||||
for(int i=0; i<formats.length; i++) {
|
for(int i=0; i<formats.length; i++) {
|
||||||
assertTrue( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
|
assertTrue(
|
||||||
|
formats[i] + " is a datetime format",
|
||||||
|
HSSFDateUtil.isADateFormat(formatId, formats[i])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then invalid ones
|
// Then invalid ones
|
||||||
@ -278,10 +287,14 @@ public class TestHSSFDateUtil extends TestCase {
|
|||||||
"yyyy*mm*dd",
|
"yyyy*mm*dd",
|
||||||
"0.0", "0.000",
|
"0.0", "0.000",
|
||||||
"0%", "0.0%",
|
"0%", "0.0%",
|
||||||
|
"[]Foo", "[BLACK]0.00%",
|
||||||
"", null
|
"", null
|
||||||
};
|
};
|
||||||
for(int i=0; i<formats.length; i++) {
|
for(int i=0; i<formats.length; i++) {
|
||||||
assertFalse( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
|
assertFalse(
|
||||||
|
formats[i] + " is not a date or datetime format",
|
||||||
|
HSSFDateUtil.isADateFormat(formatId, formats[i])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// And these are ones we probably shouldn't allow,
|
// And these are ones we probably shouldn't allow,
|
||||||
|
Loading…
Reference in New Issue
Block a user