<br>warning ....deprecated </br>
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   PhiDi_TranThi
Posted On:   Wednesday, July 10, 2002 06:22 AM


Hi, if someone could help !!!




The following line of code is where I got the warning from:



m_log.print(new Date().toGMTString() + " Starting IMS Server Thread...");


And the warning message is:

"warning: toGMTString() in java.util.Date has been deprecated"


The warning is pointing to operator "new". How to fix this? And what causes deprecation to happen in Java?


Thanks in advance for your help.



PhiDi Tran

Re: <br>warning ....deprecated </br>

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, July 10, 2002 06:47 AM


And what causes deprecation to happen in Java?



The author of the library causes the warning, by marking the method deprecated in its javadoc. You can do it yourself too, by putting "@deprecated" in the javadoc comment preceding a method in your code.



This is so you will know that you are using something which is old and out of date, and which may disappear in a future version of the library.



So, you should switch to the newer way to do whatever it is that you are trying to do.



When you get a deprecation warning, you need to look the methods up, in the J2SE javadoc at sun.com, because that's where the "deprecated" warning is coming from in the first place.

Re: <br>warning ....deprecated </br>

Posted By:   Lasse_Koskela  
Posted On:   Wednesday, July 10, 2002 06:37 AM

Deprecation is a way of removing dying features of the Java APIs with an interval so that when the new version of J2SE comes out, your code doesn't just stop compiling.


If a method is deprecated, it means that:

1) It's about to be removed from the API

2) You should avoid using it, and start replacing deprecated parts of your code with something else.


For example, all the useful methods of the java.util.Date class have been deprecated since JDK1.1 with replacing methods in java.util.Calendar.


As for your question about fixing this...

Either A) ignore the warning, or B) start using java.util.Calendar.

About | Sitemap | Contact