Android Question DateTime.GetHour problem

Przemek

New Member
Licensed User
Longtime User
Hi my question is why DateTime.GetHour show different hour in Android 4.4 and 5.1 and what to do to have same hour
Android 4.4.4 show me 0
Android 5.1 show me 1
thanks

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim st As String
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim p As Panel
    Dim l As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    p.Initialize("p")
    l.Initialize("l")
    Activity.AddView(p,0,0,100%x,100%y)
    p.AddView(l,0,30dip,100%x,200dip)
   
    l.Gravity=Gravity.CENTER
    Dim ticks As Long = DateTime.TicksPerHour
'    Dim ticks As Long = 0
   
    st=" day = " & DateTime.GetDayOfYear(ticks) & _
     " month = " & DateTime.GetMonth(ticks) & _
     " h = " & DateTime.GetHour(ticks) & _
      " m = " & DateTime.GetMinute(ticks) & _
      " s = " & DateTime.GetSecond(ticks)
   
   
    l.Text=st
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • test.apk
    116.2 KB · Views: 232

DonManfred

Expert
Licensed User
Longtime User
Dim ticks As Long = DateTime.TicksPerHour
' Dim ticks As Long = 0

st=
" day = " & DateTime.GetDayOfYear(ticks) & _
" month = " & DateTime.GetMonth(ticks) & _
" h = " & DateTime.GetHour(ticks)

ticks should hold a DATE-Long... Not just the value of "TicksperHour"

B4X:
Dim ticks As Long = DateTime.Now
st=" day = " & DateTime.GetDayOfYear(ticks) & _" month = " & DateTime.GetMonth(ticks) & _" h = " & DateTime.GetHour(ticks)
 
Upvote 0

Przemek

New Member
Licensed User
Longtime User
but I did timer and on some phone start counting from 00:00:00 and another from 01:00:00 but I sorted now thank you
I add line:
h = h - DateTime.GetHour(0)
 
Upvote 0
Top