原先的写法在运行时没有错,但是在读代码的时候,会发现按住ctrl点击`format(((Long) obj))`时,仍会定位到 `String format(final Object obj)`上,给人一种可能会栈溢出的错觉。
@see https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
This commit is contained in:
申劭明
2021-07-13 08:18:13 +00:00
committed by Gitee
parent bee3056844
commit d2603db547

View File

@@ -299,7 +299,7 @@ public class FastDatePrinter extends AbstractDateBasic implements DatePrinter {
} else if (obj instanceof Calendar) {
return format((Calendar) obj);
} else if (obj instanceof Long) {
return format(((Long) obj));
return format(((Long) obj).longValue());
} else {
throw new IllegalArgumentException("Unknown class: " + (obj == null ? "<null>" : obj.getClass().getName()));
}