Android Question DateDialog.DateTicks + TimeDialog.TimeTicks = ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

How to make correctly a single Long ticks value, if to choose by 2 dialogs, date and time ? Including the local time...
Just adding is wrong...
 

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
Hi, you can use DateUtils.
Try this:

B4X:
DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
Dim d As Long

d=DateTime.DateParse("2018-02-24 00:00:00")
  
Dim t As Long
t=DateTime.TimeParse("08:00:00")
          
Dim p As Period
  
p.Hours = DateTime.GetHour(t)
p.Minutes = DateTime.GetMinute(t)
p.Seconds = DateTime.GetSecond(t)
  
Dim NextTime As Long = DateUtils.AddPeriod(d, p)
  
Log(DateTime.Date(NextTime))
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, but question is about exactly dialogs and values that they return.
 
Upvote 0

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
Thanks, but question is about exactly dialogs and values that they return.
This works for me.

B4X:
DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
   
Dim d As Long = DateDialog.DateTicks
Dim t As Long = TimeDialog.TimeTicks
   
Dim p As Period
   
p.Hours = DateTime.GetHour(t)
p.Minutes = DateTime.GetMinute(t)
p.Seconds = DateTime.GetSecond(t)
   
Dim NextTime As Long = DateUtils.AddPeriod(d, p)
   
Log(DateTime.Date(NextTime))

Excuse me if I'm wrong.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
This works for me.

Thanks much, it really works !
I just wanted to understand what values are returned by the dialogs, as their Long values cannot be just summed. TimeDialog returns the negative long value.
I mean - how to calculate the single long result from the two dialogs results without extra funсtions, just by arithmetics
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…