Android Question Time Format issue

Declan

Well-Known Member
Licensed User
Longtime User
I am populating three CustomListView with a range of times at 15min intervals.
The code is:

B4X:
    Dim myCount As Int
    Dim t As Long = Add15Minutes("06:30 AM")
        For myCount = 1 To 49
           If t > 0 Then
               t = Add15Minutes((DateTime.Time(t)))
               DateTime.TimeFormat = "hh:mm a"
            Log(DateTime.Time(t))
            clvEvents.Add(CreateListItemEvents((DateTime.Time(t)), clvEvents.AsView.Width, 50dip), 50dip, (DateTime.Time(t)))  
            clvClasses.Add(CreateListItemClasses((DateTime.Time(t)), clvClasses.AsView.Width, 50dip), 50dip, (DateTime.Time(t)))  
            clvSports.Add(CreateListItemSports((DateTime.Time(t)), clvSports.AsView.Width, 50dip), 50dip, (DateTime.Time(t)))  
          End If
      Next
This works and the times are inserted.
But the time format is incorrect, it "jumps" from:
01:00 PM
to
01:15 AM
but should be 01:15 PM

Complete log:
 

klaus

Expert
Licensed User
Longtime User
I would have done it that way:
B4X:
Private myCount As Int
DateTime.TimeFormat = "hh:mm a"
Private Min15 = 900000 As Long
Private t = DateTime.DateTimeParse(DateTime.Date(DateTime.Now), "06:45 AM") As Long
For myCount = 0 To 48
   t = t + Min15
   Log(DateTime.Time(t))
   clvEvents.Add(CreateListItemEvents((DateTime.Time(t)), clvEvents.AsView.Width, 50dip), 50dip, (DateTime.Time(t)))   
   clvClasses.Add(CreateListItemClasses((DateTime.Time(t)), clvClasses.AsView.Width, 50dip), 50dip, (DateTime.Time(t)))   
   clvSports.Add(CreateListItemSports((DateTime.Time(t)), clvSports.AsView.Width, 50dip), 50dip, (DateTime.Time(t)))   
Next
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Thanks Klaus. Your solution works great and no time format issue.
(Took me almost a day to get my version running"
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…