Android Question Date parse

Yngveh58

Member
Licensed User
Hello
Test with Samsung S5 Android ver 6.0.1
I get errors when I try to parse following string "09 Jul 2016 06:30:42"
When I parses a date in the example. January I get in return a string "jan.".
I parses example Mars I get in return "mars".
All months except Mars, June, July retunerar correct date t date format MMM, which
should consist of three letters.
Does anyone have an explanation for this.
With B4J same code works flawlessly ..

My Code:
B4X:
	Try
	'Ta fram filens tidstämpel	
			Str="09 Jul 2016 09:14:23 GMT"
		
		Str=Str.SubString2(0,Str.IndexOf("GMT"))
		Str=Str.Trim

		Dim l As Long
		DateTime.DateFormat ="dd MMM yyyy"
		DateTime.TimeFormat="HH:mm:ss"
		
		Log(DateTime.DateParse(Str.SubString2(0,12).Trim))
		Log(DateTime.TimeParse(Str.SubString(12).trim))
		
		l=DateTime.DateTimeParse(Str.SubString2(0,12).Trim,Str.SubString(12).trim)
		l=l+(DateTime.TimeZoneOffset * DateTime.TicksPerHour)
		Str=DateTime.Date(l) & " " & DateTime.Time(l)
	
		Str=Str.trim
		Log(Str)
			
	Catch
		Log(LastException.Message)
	End Try
 

Erel

Administrator
Staff member
Licensed User
Upvote 1
Top