-1

我想将 UTC 时间转换为 IST 时间。但我得到了以下格式的时间。时间 = 111524.000 请让我知道如何将上述格式转换为 IST 格式

我尝试了下面的代码,但它对我不起作用

Dim str As String = "111524.000"
Dim formats As String() = New String() {"HH:mm:ss"}
Dim dt As DateTime = DateTime.ParseExact(str, formats, System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.AdjuToUniversal)
Dim strTime As String = dt.ToShortTimeString()

我想要时间为 11:15:24

4

1 回答 1

1
    Dim str As String = "111524.000" 'UTC Time
    Dim formats As String = "HHmmss.fff"
    Dim dt As DateTime = DateTime.ParseExact(str, formats, System.Globalization.CultureInfo.InvariantCulture, Globalization.DateTimeStyles.AssumeUniversal Or Globalization.DateTimeStyles.AdjustToUniversal)
    Dim strTime As String = dt.ToString

    Debug.WriteLine(dt.ToString & " " & dt.Kind.ToString)

    Dim IST As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")
    Dim ISTdt As DateTime = TimeZoneInfo.ConvertTime(dt, IST)

    Debug.WriteLine(ISTdt.ToString & " " & ISTdt.Kind.ToString)
于 2013-10-28T14:00:48.390 回答