'Unix Timestamp to HH-mm-ss

I'm converting UnixTimeSpan to Date, but I want to display just the Hours-Minutes-Seconds of it. I'm trying with:

Public Shared Function UnixTimeStampToDateTime(ByVal unixTimeStamp As Double) As DateTime
        Dim dtDateTime As System.DateTime = New DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc)
        dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime()
              Return dtDateTime
    End Function

which return a correct datetime

02/15/2022 20:23:24

but when I'm trying to display just The Hours-Minutes-seconds with:

 RichTextBox1.Text= UnixTimeStampToDateTime(CDbl(unxTS.tostring("HH:mm:ss")))

I'm getting the error:

System.InvalidCastException: 'Conversion from string "HH:mm:ss" to type 'Double' is not valid.'

What is the problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source