Hi all
I use this code to get number of milliseconds from the beginning of the day:
B4X:
DateTime.TimeFormat = "HH:mm:ss.SSS"
Dim m As String=DateTime.Time(DateTime.Now)
Log(m)
' if the device default language is Arabic it gives ١٥:٢٩:١٧.٨٨٦
m=m.Replace(":"," ")
m=m.Replace("."," ")
Dim r() As String=Regex.Split(" ",m)
Dim q,qq,qqq,qqqq As Int
q=r(0) : qq=r(1) : qqq=r(2) : qqqq=r(4)
mls=q*3600000+qq*60000 +qqq*1000+qqqq
the code is working very well, But if the device default language is Arabic it gives this error:
B4X:
(NumberFormatException) java.lang.NumberFormatException: For input string: "١٥"
Happy New Year every one , i have a simple issue i am trying to use the date of the phone to grab some information from a database database date is in english which means if the phone date is in arabic the client cannot grab any data from the destination i have tried to work around this...
It should be : q=r(0) : qq=r(1) : qqq=r(2) : qqqq=r(3). It is probably a typo on your end.
Anyway, I think there is an easier way to get the results than with your code because DateTime.Time(DateTime.Now) is affected by the time zone.
Here is how I would have done it:
B4X:
DateTime.DateFormat="MM/dd/yyyy" 'or use your preferred format with the day first
Dim ts As Long = DateTime.DateParse(DateTime.Date(DateTime.Now))
DateTime.DateFormat="MM/dd/yyyy HH:mm:ss.SSS"
Dim te As Long = DateTime.Now
Dim t As Long =te-ts
Log(t)