Pendrush Well-Known Member Licensed User Longtime User Feb 6, 2017 #1 I'm getting this error on some devices Code: java.text.ParseException: Unparseable date: "Sun, 05 Feb 2017 22:06:02 +0100" (at offset 0) with this code 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.
I'm getting this error on some devices Code: java.text.ParseException: Unparseable date: "Sun, 05 Feb 2017 22:06:02 +0100" (at offset 0) with this code 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.
Erel B4X founder Staff member Licensed User Longtime User Feb 6, 2017 #2 Your code will fail on devices with non-English locales. Add this code to Service_Create of the starter service: Code: 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
Your code will fail on devices with non-English locales. Add this code to Service_Create of the starter service: Code: 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.