构造函数Date(...)已被弃用。这是什么意思? (Java) [英] The constructor Date(...) is deprecated. What does it mean? (Java)

查看:334
本文介绍了构造函数Date(...)已被弃用。这是什么意思? (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 )已被弃用。

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,hrs,min)

  • GregorianCalendar(year + 1900, month, date, hrs, min).

根据建议的 API文档

这篇关于构造函数Date(...)已被弃用。这是什么意思? (Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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