Android Question How to get the current date?

helmut25

Member
I am desperately trying to get the current time and date, without success ;-(
this is my code (b4xpages)
B4X:
  DateTime.TimeFormat = "hh:mm"
   DateTime.DateFormat = "dd.MMM.yyyy"
   datex =  DateTime.Time(DateTime.Now)

the variable datex remains empty. I included the DateUtils library, but to no avail.
the compiler doesn't even throw an error messge.
any suggestions?
 

helmut25

Member
What is the output of Log(datex) ?
thanx for your very quick answer.
I was just about to delete my question, because i found out that I had to include the
XUI Views library instead of the DateUtils library.....there obviously is no documentation about that.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
This definitely works:
B4X:
Dim datex As String
    DateTime.TimeFormat = "hh:mm"
    DateTime.DateFormat = "dd.MMM.yyyy"
    datex =  DateTime.Time(DateTime.Now)
    Log(datex)  'shows the current time without PM or AM
 
Upvote 0
Top