+ Start a Discussion
TCS CRMOnDemandTCS CRMOnDemand 

Convert String representation of Datetime into Datetime Object / Instance

Frnds,
 
There's a Date String that comes from email Header , it looks as follows
Mon, 29 Oct 2007 16:41:45 +0530
 
The need is to now construct a Datetime object using the string representation of date, i tried but couldnt get to proper construction of Datetime object of the same
 
Can anyone help with conversion of datetime String to Datetime object ?
 
 
 
 
 
TCS CRMOnDemandTCS CRMOnDemand

Hi ,

DateTime object provides the static method valueOf(). This method takes input as string and returns new DateTime object. One thing here, the string you are passing for this method should be in format of  "yyyy-MM-dd HH:mm:ss".

So convert the date into this format. and then pass to valueOf method. It will return datetime object as expected.

Hope this will help you.

- V.R.