【发布时间】:2010-01-04 14:16:53
【问题描述】:
我正在尝试像这样创建Date:
date = new Date(year-1900, mon-1, day, hrs, min, sec);
Eclipse 给了我这个警告:“构造函数 Date(int, int, int, int, int) 已弃用”。
构造函数被弃用是什么意思,我能做什么?
【问题讨论】:
-
如果您要使用日期,请不要忘记至少查看 Apache Commons lang;各种实用程序(其中包括 DateUtils),这使得处理日期(和字符串)变得不那么麻烦。见commons.apache.org/lang
-
更重要的是,至少从 Java 8 开始:查看java.time, the modern Java date and time API。
标签: java date constructor deprecated