Calendar.before(Object when),为什么Object? [英] Calendar.before(Object when), why Object?

查看:298
本文介绍了Calendar.before(Object when),为什么Object?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Calendar.before(Object when)的javadoc:

返回此日历是否表示时间之前由指定的对象表示的时间。此方法等效于:

Returns whether this Calendar represents a time before the time represented by the specified Object. This method is equivalent to:

compareTo(when) < 0

当且仅当when是一个日历实例。

if and only if when is a Calendar instance. Otherwise, the method returns false.

为什么接受一个对象,如果当某人传递的东西不是一个日历实例,它返回false?为什么不只是接受一个日历实例?

Why does it accepts an Object if when someone passes something that's not a Calendar instance it returns false? Why not just accepting a Calendar instance? This kept me watching for uncorrect results in a functionality for quite some time.

推荐答案

我认为没有什么特别的原因。 java.util.Calendar 有一些我们不得不生活的设计问题。不幸的是。

I think there is no particular reason for that. java.util.Calendar has some design issues we have have to live with, unfortunately.

这篇关于Calendar.before(Object when),为什么Object?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆