Topic: 请问一个关于日期的问题servlet的

  Print this page

1.请问一个关于日期的问题servlet的 Copy to clipboard
Posted by: agagag
Posted on: 2004-02-23 20:02

Date now = new Date();
int year=now.getYear()+1900;
int month=now.getMonth()+1;
int day=now.getDate();

以上代码编译的时候却提示

"Test1.java": getYear() in java.util.Date has been deprecated at line 18, column 18
"Test1.java": getMonth() in java.util.Date has been deprecated at line 19, column 19
"Test1.java": getDate() in java.util.Date has been deprecated at line 20, column 17
There have been deprecation warnings. Please consult the documentation for a better alternative.

如何解决,但是可以用可以完成编译,但总觉得不爽!

2.Re:请问一个关于日期的问题servlet的 [Re: agagag] Copy to clipboard
Posted by: safe
Posted on: 2004-02-23 21:09

You can use java.util.Calendar.get()

3.Re:请问一个关于日期的问题servlet的 [Re: agagag] Copy to clipboard
Posted by: tintin365
Posted on: 2004-02-26 09:25

java.util.Date这个类的所有getXXXX()方法基本上都depreciated了。所以应该如果想爽的话,应该用Calender或者GregorianCalaender类


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923