Else If Name = "dagsetning" Then
Dim data As Long
data = DateTime.DateParse(Text.ToString)
'DateTime.DateFormat = "yyyy-MM-dd"
DateTime.DateFormat ="MM/dd/yyyy"
Dim DateString As String
dagsetning_titill = DateTime.date(data)
End If
For parsing a datestring you have to set the correct dateformat:
B4X:
Dim data As Long
Dim datestring as String
DateTime.DateFormat = "yyyy-MM-dd'T'HH:mm:ss"
data = DateTime.DateParse(Text.ToString)
DateTime.DateFormat = "yyyy-MM-dd"
datestring = DateTime.date(data)
Sub Activity_Create(FirstTime As Boolean)
Log(ParseDate("2012-07-18T10:46:36"))
End Sub
Sub ParseDate(s As String) As String
DateTime.DateFormat = "yyyy-MM-dd"
Dim data As Long
data = DateTime.DateParse(s)
DateTime.DateFormat = "MM/dd/yyyy"
Return DateTime.Date(data)
End Sub