Android Question Parsing a time string into a long integer

Lakhtin_V

Active Member
Licensed User
Longtime User
How should a string containing the date and time separately be formatted? I need to convert string date and time values into a long integer in milliseconds that is associated with a time of type 1704..... What separating characters should I use to describe the date and time. So far I'm getting an error all the time.
TimeParse:
            strTime=strH & ":" & strM & ":" & strS
            strDen=DateTime.Date(DateTime.Now)
            Log( Sentence & "    " & strDen & "    " & strTime)
            Main.GNSSTime = DateTime.DateTimeParse(strDen,strTime)
1710247719048.png

1710247634663.png
 

Lucas Siqueira

Active Member
Licensed User
Longtime User
use lib dateUtils, native in IDE (B4A, B4I, B4J)

Log( DateUtils.SetDateAndTime(2024, 03, 12, 10, 12, 39) )

1710249230188.png



or


DateTime.DateFormat = "MM/dd/yyyy"
Log( DateTime.DateTimeParse("03/12/2024","10:12:39") )

1710249487845.png
 
Upvote 0
Top