Hello, I'm trying to parse both a date and time. I have a user select both date and time from a dialog. It returns the value as String such as "Wed Jan 24 19:32:16 MST 2018" , and I'm trying to get it in ticks:
The full_date is what is returned as string. The hour returns the hour selected from the dialog. If the user has clock in 24 hour format, it fails so I have it change the date format.
If it try to run it with a non-English locale then it fails. So I have this in Service Create sub in the Starter module.
The code works, but then other areas of my app that show the date/time also get shown in English locale. How can I leave those unchanged?
B4X:
DateTime.DateFormat = "EEE MMM dd hh:mm:ss Z yyyy"
If hour >12 Then DateTime.DateFormat = "EEE MMM dd HH:mm:ss Z yyyy"
Dim lngdate As Long = DateTime.DateParse(full_date)
log(lngdate)
If it try to run it with a non-English locale then it fails. So I have this in Service Create sub in the Starter module.
B4X:
Dim jo As JavaObject
jo.InitializeStatic("java.util.Locale").RunMethod("setDefault", Array(jo.GetField("US")))
The code works, but then other areas of my app that show the date/time also get shown in English locale. How can I leave those unchanged?