构造函数Date(...)已被弃用。这是什么意思? (Java) [英] The constructor Date(...) is deprecated. What does it mean? (Java)
问题描述
我试图创建一个像这样的日期:
I'm trying to create a Date like this:
date = new Date(year-1900,mon-1,day,hrs,min,sec);
并且Eclips给我这个警告:构造函数Date(int,int,int,int,int )is deprecated。
and Eclips gives me this warning: "The constructor Date(int,int,int,int,int) is deprecated".
构造函数被弃用意味着什么?我可以做什么?
What does it mean for a constructor to be deprecated? What can I do?
推荐答案
已弃用字面意味着被拒绝,但更准确的翻译已退休。 已弃用表示此方法仍然可用,但不应使用它。它将逐步被淘汰。有一种新方法可以做同样的事情。已弃用的方法标有一个特殊的Javadoc注释:
Deprecated literally means disapproved of, but a more accurate translation would be retired. Deprecated means this method is still usable, but you should not use it. It will gradually be phased out. There is a new method to do the same thing. Deprecated methods are marked with a special Javadoc comment:
/**
*@deprecated Please now use newMethod()
*@see newMethod()
*/
/ strong>:
Use:
-
Calendar.set(year + 1900,month,date,hrs,min) code>
或
-
GregorianCalendar(year + 1900,month,date,hours,min)
。
GregorianCalendar(year + 1900, month, date, hrs, min)
.
正如建议的 API文档 。
这篇关于构造函数Date(...)已被弃用。这是什么意思? (Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!