提交 2d9804ca authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix parsing of negative TIME values with 0 hours

上级 3a86effd
...@@ -403,8 +403,11 @@ public class DateTimeUtils { ...@@ -403,8 +403,11 @@ public class DateTimeUtils {
} }
boolean negative; boolean negative;
hour = Integer.parseInt(s.substring(start, s1)); hour = Integer.parseInt(s.substring(start, s1));
if (hour < 0) { if (hour < 0 || hour == 0 && s.charAt(0) == '-') {
if (timeOfDay) { if (timeOfDay) {
/*
* This also forbids -00:00:00 and similar values.
*/
throw new IllegalArgumentException(s); throw new IllegalArgumentException(s);
} }
negative = true; negative = true;
......
...@@ -117,6 +117,7 @@ public class TestDate extends TestBase { ...@@ -117,6 +117,7 @@ public class TestDate extends TestBase {
assertEquals("00:00:00", ValueTime.fromNanos(0).getString()); assertEquals("00:00:00", ValueTime.fromNanos(0).getString());
assertEquals("23:59:59", ValueTime.parse("23:59:59").getString()); assertEquals("23:59:59", ValueTime.parse("23:59:59").getString());
assertEquals("99:59:59", ValueTime.parse("99:59:59").getString()); assertEquals("99:59:59", ValueTime.parse("99:59:59").getString());
assertEquals("-00:10:10", ValueTime.parse("-00:10:10").getString());
assertEquals("-99:02:03.001002003", assertEquals("-99:02:03.001002003",
ValueTime.parse("-99:02:03.001002003").getString()); ValueTime.parse("-99:02:03.001002003").getString());
assertEquals("-99:02:03.001002", assertEquals("-99:02:03.001002",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论