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:
** Activity (main) Create, isFirst = true **
07:00 AM
07:15 AM
07:30 AM
07:45 AM
08:00 AM
08:15 AM
08:30 AM
08:45 AM
09:00 AM
09:15 AM
09:30 AM
09:45 AM
10:00 AM
10:15 AM
10:30 AM
10:45 AM
11:00 AM
11:15 AM
11:30 AM
11:45 AM
12:00 PM
12:15 PM
12:30 PM
12:45 PM
01:00 PM
01:15 AM
01:30 AM
01:45 AM
02:00 AM
02:15 AM
02:30 AM
02:45 AM
03:00 AM
03:15 AM
03:30 AM
03:45 AM
04:00 AM
04:15 AM
04:30 AM
04:45 AM
05:00 AM
05:15 AM
05:30 AM
05:45 AM
06:00 AM
06:15 AM
06:30 AM
06:45 AM
07:00 AM
** Activity (main) Resume **
igutgtutc
** Activity (main) Pause, UserClosed = true **
 

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
Top