String to Date in Java -
Hi,
I am converting string to date format. But this gives an incorrect date, for example,
string start date = "08-05-2010"; // (mm / dd / yyyy)
I want to convert it to "date" object like this, 05-JUL-10
How to do this? I tried this kind of
SimpleDataformat dateformat = New SimpleDateform ("DD-MMM-OR"); Scal1.setTime (dateFormat.parse (STARTDATE));
But I'm getting an "ineffective date".
If you want to convert a format to any format in a date string in another format, then You can use class formats () and pars () methods
Before you set the string to the purse () method format pattern and then setting the format () method to the target object Format:
SimpleDateFormat sourceFormat = New SimpleDateFormat ("MM-dd-yyyy"); Date source format Dat = sourceFormat.parse ("08-05-2010"); SimpleDateFormat destFormat = New SimpleDateFormat ("dd-MMM-yy"); String distorted datastring = difference format (sourceFormatDate); Println (destFormatDateString); // 05-Aug-10
Comments
Post a Comment