Android Question Add mintus to time based on EditText

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I have an EditText with "07:45". I want to do this plus 30 minutes.

What will be the correct way?

Best regards,
André
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim t As Long = Add30Minutes("07:45")
   If t > 0 Then
     Log(DateTime.Time(t))   
   End If
End Sub

Sub Add30Minutes(s As String) As Long
   DateTime.TimeFormat = "HH:mm"
   Try
     Dim t As Long = DateTime.TimeParse(s)
     Dim p As Period
     p.Minutes = 30
     t = DateUtils.AddPeriod(t, p)
     Return t
   Catch
     Log("Invalid string.")
     Return 0
   End Try
End Sub
 
Upvote 0
Top