A few days ago, i implemented the library of @corwin42 with the name ahlocale.
My Problem was, i had a DateTime value from the database and I had to split it up and adjust it.
As I have solved this, I will show here times:
My Value from the database looks so: 2017-07-25 13:00:00
Now to the code:
and it works now without problems.
i hope it helps you.
My Problem was, i had a DateTime value from the database and I had to split it up and adjust it.
As I have solved this, I will show here times:
My Value from the database looks so: 2017-07-25 13:00:00
Now to the code:
B4X:
'from the lib. AHLocale
Dim du As AHDateUtils
'our DateTime value
Dim DateString AsString = "2017-07-25 13:00:00"
'split the string into 2 parts
Dim parts() AsString = Regex.Split("\s", DateString) '\s = whitespace character
'We must adjust the DateFormat
DateTime.DateFormat = "yyyy-MM-dd"'
'Declare a variable, so we can the splittet value, put it in after parsing
Dim Ticks As Long = DateTime.DateTimeParse(parts(0), parts(1))
'now we can call:
lbl_mylabel.Text = du.GetRelativeTimeSpanString(Ticks , DateTime.Now, DateTime.TicksPerMinute, 0)
and it works now without problems.
i hope it helps you.
Last edited: