Android Question Converting a string

Sergey_New

Well-Known Member
Licensed User
Longtime User
Please tell me how to convert the string "21/01/2020" to "01/21/2020".
I need this to get ticks from a date in "MM.dd.yyyy" format using DateTime.DateParse
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I wonder how you knew that stuff, GEDCOM!
Gedcom is not a new Format. It´s base is from 1985 already.
Genealogy by itself is also not new ;-)
 
Upvote 0

emexes

Expert
Licensed User
Longtime User
GEDCOM files

If the original data is dates, then is usually better to keep it as dates, rather than needlessly converting it to ticks and back, because sometimes that doesn't work the way you'd expect, eg if the conversion to ticks is encoded on a device with one time zone setting and decoded on another device that has a different time zone setting, or you have date ranges crossing daylight-savings boundaries.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Now you are familiar with the GEDCOM standard :)
I have attached a working example.
The example sets out my request.
Oops.
Forgot to delete comments. The example works correctly.
 

Attachments

  • Test.zip
    3.8 KB · Views: 16
Last edited:
Upvote 0

emexes

Expert
Licensed User
Longtime User
sometimes that doesn't work the way you'd expect

Example: today is 24 years since 911 but fall of north tower on 11-Sep-2001 actually happened here on 12-Sep-2001.

Albeit not by much: I remember watching the first tower fall, and then there was a click and the tv went dead which freaked me out a bit, until I realised it was the powerpoint timer that I'd set up to turn the tv off every midnight to deal with my habit of falling asleep in front of the tv.
 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User
Please tell me how to convert the string "21/01/2020" to "01/21/2020".
I need this to get ticks from a date in "MM.dd.yyyy" format using DateTime.DateParse

I created some formatting and conversions of dates and other formats


B4X:
Dim date1 As String = "21/01/2020"
Dim date2 As String = br.data.data(date1, "dd/MM/yyyy", "MM/dd/yyyy")
Log("date1: " & date1)
Log("date2: " & date2)
 
Upvote 0
Top