Android Question Format String into Date

Peter Faase

Member
Licensed User
Longtime User
Howdy,

I am completly new and i am sure i am missing something but i really can't get my head around it.

I would apprieciate a little help on this matter

I connect my app to a MySql database, so far so good. All works fine (thanks Andre ;-) ) but now here's the point i struggle with:

I have a label on my screen and want to fill that with a a date out of the database, i use the following command:

lblGebDatum.Text=m.Get("gebdatum")

I get a nice string back as: "1908-08-27" and that one is put on the label..
But i don't want it this way i want is formatted to the Dutch date format so: 27-08-1908.

I allready tried the use of Datetime.

datetime.DateParse (m.Get("gebdatum") but that doesn't work for me.

Any help is welcome!

Cheers,

Peter
 
You can do something like this:
Code: Copy
Dim strDate As String="1908-08-27"
Dim lngDate As Long
DateTime.dateformat="yyyy-MM-dd"
lngDate= DateTime.DateParse(strDate)
DateTime.dateformat="dd-MM-yyyy"
lblDate.Text=DateTime.Date(lngDate)
Msgbox(lblDate.text,"") 'Displays 27-08-1908

And if you do not want to make use of the DateTime function here is another method:
Code: Copy
Dim strDateArray() As String
Dim strDate As String="1908-08-27"
strDateArray=Regex.Split("-",strDate)
lblDate.Text=strDateArray(2) & "-" & strDateArray(1) & "-" & strDateArray(0)
Msgbox(lblDate.Text,"") 'Displays 27-08-1908
 
Last edited:
Upvote 0
Try this .. might not be most efficient way ..

Code: Copy
Dim MyDate  As Long  'store working date as ticks
   
DateTime.DateFormat = "yyyy-mm-d"
MyDate = DateTime.DateParse("1908-08-27")
Log (MyDate)
       
DateTime.DateFormat = "d-mm-yyyy"
Log(DateTime.Date(MyDate))

Cheers mj
 
Upvote 0
Back
Top