VB净NTP时间加1小时 [英] VB net NTP time add 1 Hour
本文介绍了VB净NTP时间加1小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我的应用程序显示ntp时间,但需要增加一小时吗?
私有 Sub sntpClient_QueryServerCompleted( ByVal sender 作为系统。对象, ByVal e 作为 QueryServerCompletedEventArgs)句柄 SntpClient1.QueryServerCompleted
如果 e.Succeeded 然后
ListView1.Items.Clear()
ListView1.Items.AddRange(新 ListViewItem(){_
_
新 ListViewItem(新 字符串()_
{字符串 .Format( {0:yyyy / MM / dd H:mm:ss},_
e.Data.ReceiveDateTime,e.Data.ReceiveDateTime.Millisecond)})})
结束 如果
结束 Sub
解决方案
您的帖子并未表述为正确的问题。如果这是一个关于如何添加一小时的问题,那么这就是:
http://msdn.microsoft.com/en-us/library/system.datetime.addhours(v = vs.110).aspx [ ^ ] 。
此外,如果你看起来有一个毫秒
的错误。在格式中,您只有一个参数,但在String.Format
调用中,您使用两个参数。您不需要第二个参数。一个DateTime
参数就足够了,只需在格式字符串中添加一个毫秒格式说明符fff。请参阅:
http:// msdn .microsoft.com / zh-CN / library / 8kb3ddd4%28v = vs.110%29.aspx [ ^ ]。
-SA
hello my application displays ntp time but needs to add one hour to do?
Private Sub sntpClient_QueryServerCompleted(ByVal sender As System.Object, ByVal e As QueryServerCompletedEventArgs) Handles SntpClient1.QueryServerCompleted
If e.Succeeded Then
ListView1.Items.Clear()
ListView1.Items.AddRange(New ListViewItem() { _
_
New ListViewItem(New String() _
{String.Format("{0:yyyy/MM/dd H:mm:ss}", _
e.Data.ReceiveDateTime, e.Data.ReceiveDateTime.Millisecond)})})
End If
End Sub
解决方案
Your post is not formulated as a correct question. If this is a question on how to add an hour, this is how:
http://msdn.microsoft.com/en-us/library/system.datetime.addhours(v=vs.110).aspx[^].
Also, if looks like you have a bug withMilliseconds
. In, format, you have only one parameter, but inString.Format
call, you use two. You don't need the second parameter. OneDateTime
parameters will be enough, only add a millisecond format specifier "fff" to your format string. Please see:
http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx[^].
—SA
这篇关于VB净NTP时间加1小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文