Android Question Unparseable date


Well-Known Member
Licensed User
Longtime User
I'm getting this error on some devices
java.text.ParseException: Unparseable date: "Sun, 05 Feb 2017 22:06:02 +0100" (at offset 0)
with this code
DateTime.DateFormat = "EEE, dd MMM yyyy HH:mm:ss Z"
Dim sDate As String = "Sun, 05 Feb 2017 22:06:02 +0100"
Dim lngDate As Long = DateTime.DateParse(sDate) '<- Error in this line

I'm unable to reproduce it on my devices, but I can see errors on live (store) application.


B4X founder
Staff member
Licensed User
Longtime User
Your code will fail on devices with non-English locales.

Add this code to Service_Create of the starter service:
Dim jo As JavaObject
jo.InitializeStatic("java.util.Locale").RunMethod("setDefault", Array(jo.GetField("US")))
This will set the default locale to be US (of the process only) and the dates will be parsed correctly.
Upvote 0