Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java version migration deprecated date methods

Tags:

java

java-5

I'm migrating from Java 1.1. to Java 5.

I notice that some methods have been deprecated e.g. java.util.Date has a getYear() method which is deprecated.

My question is if the getYear() method is left as it is in 1.1 will it still function in Java 5

like image 912
AJM Avatar asked Feb 22 '10 15:02

AJM


2 Answers

Yes, it will just work as it was. It's only eligible for removal in future Java SE versions. The deprecation is purely documental and just gives you room to update the code in the meanwhile.

Currently, you're supposed to use either the methods of java.util.Calendar or the much more improved JodaTime API. The replacement for date/time API's in standard Java SE will be similar to JodaTime and is still due to come (JSR-310). It was planned for JDK7, but unfortunately it doesn't seem to be in time.

like image 185
BalusC Avatar answered Oct 26 '22 23:10

BalusC


It will still function, even though it is deprecated. They replaced it by a 'better one' (Calendar.get(Calendar.MONTH).), but the original is left there for the purpose of backwards compatibility. So it's no problem to use it in your case.

like image 30
Fortega Avatar answered Oct 26 '22 22:10

Fortega