Android Question Wrong period of two date

devmobile

Active Member
Licensed User
Hello
I use DateUtil class in my app
I use below code
B4X:
Dim p1 As Period
p1    =    DateUtils.PeriodBetween(ln,DateTime.Now)

ln variable is DateTime.Now value that i save it 2 days ago
But the PeriodBetween of two date is wrong
Why?
 

devmobile

Active Member
Licensed User
I add notify to file
B4X:
Public Sub AddNotification(Message As String,DateTimes As Int)
   
    Dim m As Map
    If File.Exists(File.DirInternal,"notification") Then
        m = File.ReadMap(File.DirInternal,"notification")
    Else
        m.Initialize
    End If
   
    m.Put(m.Size + 1 , Library.Map2Json(CreateMap("message":Message,"time":DateTimes)))
   
    File.WriteMap(File.DirInternal,"notification",m)
   
End Sub

Sub Map2Json(Data As Map) As String
   
   If Data = Null Then Return "{}"
   If Data.IsInitialized = False Then Return "{}"
   
   Dim js As JSONGenerator
   js.Initialize(Data)
   Return js.ToString
   
End Sub
 
Upvote 0
Top