File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Using Deprecated API in Code
Joined: Aug 31, 2004
Jul 24, 2005 23:23:00
Need your comments regarding this.
I have to make a code which does the following
1. Get a date, which is passed as a
2. Format the date in desirable "dd-MMM-yyyy" format.
I plan to do the following
datePattern = "dd-MMM-yyyy"; SimpleDateFormat dForm = new SimpleDateFormat("yyyy/mm/dd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/mm/dd"); Date theDate = new Date(strDate);(1) dateFormat.applyPattern(datePattern); System.out.println("Formatted Date : "+dateFormat.format(theDate));
I know that (1) has been deprecated. I would like to know, what will the impact be, if I am using it in my code. And what would be the suitable alternative?
Thanks in advance for your kind help....
Joined: Jan 24, 2005
Jul 25, 2005 01:00:00
Calendar cal = Calendar.getInstance(); /* use the numerous set methods to set your date value One option would be set(int year, int month, int date, int hourOfDay, int minute, int second) -- Sets the values for the fields YEAR, MONTH, DAY_OF_MONTH, HOUR, MINUTE, and SECOND. */ Date dt = cal.getTime();
Impact of using deprecated api:
When an api is tagged 'deprecated', it means that it wouldnt probably be supported in future versions - so probably this code, say, 10 years from now
on the latest
platform at that time, would give bizzare output.
Joined: Jan 29, 2003
Jul 25, 2005 07:34:00
You have some
objects here ... look at the parse() method to create a Date.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Using Deprecated API in Code
Formatting the date
Behaviour of parse() method in SimpleDateFormat
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014