Android Question Convert String to Long

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
I need to get the name of a day.
I set the date with the http://www.b4x.com/android/forum/threads/wheelview-library.17028/#content library and I get a string result.

How I convert it to long and use
B4X:
Public Sub GetDayOfWeekName(Ticks As Long) As String
    Dim df As String = DateTime.DateFormat
    DateTime.DateFormat = "EEEE"
    Dim res As String = DateTime.Date(Ticks)
    DateTime.DateFormat = df
    Return res
End Sub
 

derez

Expert
Licensed User
Longtime User
If you use the wheel like in the demo program, the following sub will return the long variable of the ticks of the date (in the demo wv1 returns the day, wv2 the name of the month from val array, wv3 the year):
B4X:
Sub getlong As Long
Dim k As Int
DateTime.DateFormat = "dd/MM/yyyy"
For i = 0 To val.Length - 1
    If wv2.ReadWheel = val(i) Then
        k = i+1
        Exit
    End If
Next
Return DateTime.DateParse(wv1.ReadWheel & "/" & NumberFormat(k,2,0) & "/" & wv3.ReadWheel)

End Sub
or use dateparse on the result string after making it look like the date format you use.
 
Last edited:
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
If you use the wheel like in the demo program, the following sub will get return the long variable of the ticks of the date (in the demo wv1 returns the day, wv2 the name of the month from val array, wv3 the year):
B4X:
Sub getlong As Long
Dim k As Int
DateTime.DateFormat = "dd/MM/yyyy"
For i = 0 To val.Length - 1
    If wv2.ReadWheel = val(i) Then
        k = i+1
        Exit
    End If
Next
Return DateTime.DateParse(wv1.ReadWheel & "/" & NumberFormat(k,2,0) & "/" & wv3.ReadWheel)

End Sub
or use dateparse on the result string after making it look like the date format you use.

it works perfectly! many thanks! :D:D
 
Upvote 0
Top