Android Question Unparseable Date

abhishek007p

Active Member
Licensed User
Longtime User
One of my app is crashing with error 'Unparseable date' The user reported that he is using 'Samsung A9' with 'Traditional Chinese' device language. this app is a birthday manager and was build using B4A v4.0

here is screenshot
Clipboard03.jpg
 

abhishek007p

Active Member
Licensed User
Longtime User
DateTime.DateFormat = "MMM dd, yyyy"

Example - March 04, 2018

the link you gave forces US Locale on users, would not they get confused ?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
the link you gave forces US Locale on users, would not they get confused ?

You could always retrieve the current locale information first, set the US locale, parse your date and then reset the default locale.

B4X:
Dim defaultLocale As JavaObject
Dim jo As JavaObject
'Safe Locale
defaultLocale = jo.InitializeStatic("java.util.Locale").RunMethod("getDefault", Null)
jo.InitializeStatic("java.util.Locale").RunMethod("setDefault", Array(jo.GetField("US")))
'
' Process your date
'
'Restore Locale
jo.InitializeStatic("java.util.Locale").RunMethod("setDefault", Array(defaultLocale))
 
Upvote 0
Top