Click to See Complete Forum and Search --> : Using Deprecated Methods
JavaTheHut
12-30-2003, 02:24 PM
I'm adding some javascript functionality within a JSP to mask a text field by converting a numeric date into a long date.
Example: User enters 12/20/2003, which is converted to December 20, 2003 via the javascript functionality.
The following are a list of methods that are part of the built-in Date object that I am using: getDate(), getMonth(), and getFullYear().
These work and function correctly but I have also found out that these are deprecated methods as of JDK version 1.1.
Does anyone know of any disadvantages of using deprecated methods within Javascript functions?
ray326
12-30-2003, 03:05 PM
I think those are Java Date methods, not Javascript. The problem with using deprecated code is that it will definitely disappear in a newer version of the JDK and there are LOTS of newer versions than 1.1 already. I believe those particular methods were impacted by Y2K-related updates and support for the new Calendar class.
JavaTheHut
12-30-2003, 03:26 PM
I'm new to javascript so you'll have to excuse me if I sound ignorant on the remaining message I am about to post...
From my understanding the Date object is a Java object that is built into Javascript functionality. Meaning you do not have to import the package in order to use this object on a JSP for instance.
I have tried using the Calendar object. Here's a snippet of the code I am using:
var lDate = new Date();
var lCalendar = Calendar.getInstance();
lCalendar.setTime(lDate);
var lDay = lCalendar.get(Calendar.DAY_OF_WEEK);
When I try to run this code, I receive an IE error stating that the Calendar object is undefined. Any ideas??
:confused:
JavaTheHut
12-30-2003, 04:00 PM
I did some research on Google and found this website. http://www.javaworld.com/javaworld/jw-05-1996/jw-05-javascript.html
Which basically states that the built-in Date object within Javascript is 'borrowed' from the Java language but slightly different.
Perhaps the deprecated version on Java's end isn't applicable with javascript.
What do you think?
ray326
12-30-2003, 10:40 PM
There's no real relationship between the two languages except the "Java" substring so what's good or not in one has no effect on the other. You can find all the docs for all the versions of Javascript at the http://devedge.netscape.com site.
Re Calendar - it's Java, not Javascript so we've actually found a case where IE is RIGHT!
JavaTheHut
12-31-2003, 08:58 AM
I knew that there was no correlation between javascript and java... although many are confused due to the simililarity in their names.
It's good to know though that I can use the built-in Date object without worries of any of the methods being deprecated. It definately saves some time in trying to find a "work-around".
Thanks for your help. :D