将字符串"11-10-10 12:00:00"转换为Date对象

Mah*_*ria 1 java date-format simpledateformat

可能重复:
如何在java中解析日期?

我想将字符串"11-10-10 12:00:00"转换为Date对象,但我无法这样做.你能帮帮我吗?

我有Date对象,其值为"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();    
 }
Run Code Online (Sandbox Code Playgroud)

小智 7

DateFormat newDateFormat = new SimpleDateFormat("dd-MM-yy HH:mm:ss");    
Date d = newDateFormat.parse("11-10-10 12:00:00");
System.out.println(d);
Run Code Online (Sandbox Code Playgroud)

这是ideone演示