且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 vb.net 中将字符串转换为日期时间

更新时间:2023-02-03 08:59:45

将解码模式传递给 ParseExact

Pass the decode pattern to ParseExact

Dim d as string = "201210120956"
Dim dt = DateTime.ParseExact(d, "yyyyMMddhhmm", Nothing)

ParseExact 可从 Net FrameWork 2.0 获得.
如果您仍然使用 1.1,您可以使用 Parse,但您需要提供适合您的字符串的 IFormatProvider

ParseExact is available only from Net FrameWork 2.0.
If you are still on 1.1 you could use Parse, but you need to provide the IFormatProvider adequate to your string