在java中将字符串转换为java.util.date格式

问题描述:

我有一个这样的字符串。

am having a string like this.

Thu Oct 07 11:31:50 IST 2010

我想将其转换为确切的日期时间格式,以将其存储在SQL中。

I want to convert this into its exact date time format to store it in SQL.

我熟悉如此多的字符串转换,如下所示。

Am familiar with so many string to date conversions like the following.

String dateString = "2001/03/09";

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/mm/dd");
Date convertedDate = dateFormat.parse(dateString); 

但是,我需要转换一个字符串,如 Thu Oct 07 11:31: 50 IST 2010
到其日期格式与时间戳。

But i need to convert a string like Thu Oct 07 11:31:50 IST 2010 into its Date format with timestamp.

任何人都可以解释将其转换为其java.util的正确方法。日期格式?

Can anyone explain the proper way of converting this into its java.util.Date format.?

尝试这样:

SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");

有关SimpleDateFormat类的未来引用,请阅读:
http://docs.oracle.com/javase/7/docs/api/java /text/SimpleDateFormat.html

For future reference read up on the SimpleDateFormat class: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html