Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic String to DateTime for .setStartTime (Read 1750 times)
henpop29
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Dec 27th, 2021
String to DateTime for .setStartTime
Dec 27th, 2021 at 4:28pm
Print Post  
Hello,

I am trying to convert the String "27/12/21 00:30:00 o'clock GMT" that was got through the .getStartTime function into a DateTime. Please can someone help me with this?

Normally .getStartTime returns a "DateTime" but due to the format I cannot store it in my database as a DataTime only a String. I have been struggling with this for a couple days now and my uni deadline is getting closer, this error has bene stopping me progressing with the rest of my application.

Any help/advice is appreciated Smiley
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: String to DateTime for .setStartTime
Reply #1 - Dec 27th, 2021 at 7:09pm
Print Post  
Hi,

There's no getStartTime method in the API returning a string. Maybe you are seeing this after some implicit conversion done by your database. You can convert from that specific format back to DateTime like this:

Code
Select All
String dateStr = "27/12/21 00:30:00 o'clock GMT";
dateStr = dateStr.replaceAll(" o'clock GMT", "");

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
DateTime dt = new DateTime(sdf.parse(dateStr)); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint