Android Question sqlite date time to datetime

TomDuncan

Active Member
Licensed User
Longtime User
hi all,
I need to convert from a sqlite date string which returns "2015-06-01 11:40:00 AM" from my server.
I need to convert this into a long so I can use Datetime.
We use dd/MM/yyyy so you can see my problem.

This is what I have tested.
It does say that the default is yyyy-MM-dd hh:mm:ss
But this throws an exception.
The server returns the values via JSON.

Any thoughts.
Tom
 

imbault

Well-Known Member
Licensed User
Longtime User
Try that:
B4X:
Dim cDateTime as string = "2015-06-01 11:40:00 AM"
Dim nTicks as Long
DateTime.DateFormat= "yyyy-MM-dd"
DateTime.TimeFormat = "KK:mm:ss a"
nTicks = DateTime.DateTimeParse( cDateTime.substring2(0,10) , cDateTime.substring(12))
 
Last edited:
Upvote 0
Top