Hi I try to parse this string date format to ticks but get error.
The String I want to convert:
2018-07-20T05:00:00Z
With DateTime:
Result: java.text.ParseException: Unparseable date: "2018-07-20T05:00:00Z"
With AHLocate:
Result: java.lang.RuntimeException: Unable to parse date string
This date come from a remote db, on my device local db I use unix ticks.
Solved. Small function. I know my code is not the best. But I try to help.
The String I want to convert:
2018-07-20T05:00:00Z
With DateTime:
B4X:
DateTime.DateFormat = "dd/MM/yy"
DateTime.TimeFormat = "HH:mm:ss a"
Log(DateTime.DateParse("2018-07-20T05:00:00Z"))
With AHLocate:
B4X:
DateTime.DateFormat = "dd/MM/yy"
DateTime.TimeFormat = "HH:mm:ss a"
Log(DateTime.DateParse("2018-07-20T05:00:00Z"))
This date come from a remote db, on my device local db I use unix ticks.
Solved. Small function. I know my code is not the best. But I try to help.
B4X:
'Accept this format: 2018-07-20T05:00:00Z
Sub convertir_fecha_string_to_ticks(Fecha_remota As String) As String
Dim Extractor_texto As String
Extractor_texto=Fecha_remota
Dim mes As String
Dim dia As String
Dim anyo As String
dia = Extractor_texto.SubString2(8,10)
mes = Extractor_texto.SubString2(5,7)
anyo = Extractor_texto.SubString2(0,4)
Return DateTime.DateParse(dia&"/"&mes&"/"&anyo)
End Sub
Last edited: