Android Question sqlite date time to datetime

Discussion in 'Android Questions' started by TomDuncan, Jul 25, 2015.

  1. TomDuncan

    TomDuncan Active Member Licensed 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.
  2. imbault

    imbault Well-Known Member Licensed User

    Try that:
    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: Jul 25, 2015
    Juzer Hussain and TomDuncan like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice