Hello Friends, I have a string in date format that is "2000-11-05 13:34:56" now i want to convet it into Date object. I found following methods which allows me to convert String object in to Date but they all are depricated and i am not able to use tem. 1. java.util.Date constructor Date(String) 2. public static long parse(String) 3. public static java.sql.Date valueOf(string) So i am not able to uses these depricated methods and can any one pls help me how to do this. Second, about depricated methods. What i know is that we can use depricated methods in our source code and it will compile with warnings. Ok this this is happening, my source code is converted into bytecode with 1 warning. Now when i run the class file it execute all the commands till it reached the statement where depricated method is used. It then ignores all the lines after that and at the same time i don't get any error message on console. In short i am not able to use any of the depricated methods. Can some one pls high light on this also.
thanks, regards, Raj.
Regards,<P>Raj.<BR>-------------------------<BR>Afforts should be Appriciated.<BR>-------------------------
Preethi Suryam
Ranch Hand
Joined: Nov 17, 2000
Posts: 92
posted
0
Hi Raj! Date(String s) is replaced by DateFormat.parse(String s) It is working fine.try it out. Good Luck Preethi.
Rajpal Kandhari
Ranch Hand
Joined: Aug 26, 2000
Posts: 126
posted
0
Hello , I tried what you suggested. DateFormat is an abstract class. SimpleDateFormat is its concrete subclass. So i created object of SimpleDateFormat class and using that object i accessed parse method of DateFormat class.
I also passed string in this format: java.util.Date date = sdf.DateFormat("2000-11-04 14:25:56"); for both the cases it gave me the following error java.text.ParseException unparse Date : "2000-11-04" or java.text.ParseException : "2000-11-04 14:25:56" Preeti can you test this thing? I am really desparate and i need a solution for this. May be i am doing something wrong. In that case pls tell me where i am going wrong. Second if you have tried this then tell me how to do it with a piece of code. Thanks regards, Raj.
Rajpal Kandhari
Ranch Hand
Joined: Aug 26, 2000
Posts: 126
posted
0
Hello , I tried what you suggested. DateFormat is an abstract class. SimpleDateFormat is its concrete subclass. So i created object of SimpleDateFormat class and using that object i accessed parse method of DateFormat class.
I also passed string in this format: java.util.Date date = sdf.DateFormat("2000-11-04 14:25:56"); for both the cases it gave me the following error java.text.ParseException unparse Date : "2000-11-04" or java.text.ParseException : "2000-11-04 14:25:56" Preeti can you test this thing? I am really desparate and i need a solution for this. May be i am doing something wrong. In that case pls tell me where i am going wrong. Second if you have tried this then tell me how to do it with a piece of code. Thanks regards, Raj.