我通过soap api oracle服务云获取此格式的日期
2016-03-08T06:20:16Z
如何通过VB中的函数翻转它?
答案 0 :(得分:0)
Function DateFlip(D As String)
Try
Dim result As String() = D.Split(New String() {"-", "T", "Z", ":"}, StringSplitOptions.None)
Dim test As Integer = CInt(result(3))
If (test > 12) Then
Return result(2) + "/" + result(1) + "/" + result(0) + " " + result(3) + ":" + result(4) + ":" + result(5) + " PM"
Else
Return result(2) + "/" + result(1) + "/" + result(0) + " " + result(3) + ":" + result(4) + ":" + result(5) + " AM"
End If
Catch e As Exception
Return ""
End Try
将此功能添加到VB类
DateFlip("2016-03-08T06:20:16Z")
答案 1 :(得分:-1)
我知道它已经得到了解答,但我在一行中有更好的代码也可以尝试我的
Dim time As String = "2016-03-08T06:20:16Z"
MsgBox(CDate(time.Substring(0, 10)).ToString("dd/MM/yyyy") +
" " +
CDate(time.Substring(11, 8)).ToString("hh:mm:ss tt"))