convert String "11-10-10 12:00:00" into Date Object

Posted by Mahendra Athneria on Stack Overflow See other posts from Stack Overflow or by Mahendra Athneria
Published on 2011-01-03T13:46:35Z Indexed on 2011/01/03 13:53 UTC
Read the original article Hit count: 257

Filed under:
|
|

Hi,

I want to convert String "11-10-10 12:00:00" into Date object but i am not able to do so.
can you please help me out?
below is the code snippet.

i have the Date obj which has the value = Mon Oct 11 00:00:00 IST 2010

DateFormat newDateFormat = new SimpleDateFormat("dd-MM-yy hh:mm:ss");    
String strDate = newDateFormat.format(tempDate);  
//**i got strDate as strDate is : 11-10-10 12:00:00**
DateFormat newDateFormat1 = new SimpleDateFormat("dd-MM-yy hh:mm:ss");    
try {    
        tempDate = newDateFormat1.parse(strDate); 
        // **getting tempDate as - Mon Oct 11 00:00:00 IST 2010**    
    } catch (ParseException e) {
        // TODO Auto-generated catch block    
        e.printStackTrace();
    }

Can someone help me to solve this issue?

Regards,
Mahendra Athneria
Mumbai, India

© Stack Overflow or respective owner

Related posts about c#

Related posts about dateformat