简体   繁体   中英

VB.NET convert date string ddMMyyhhmmss to Date Object

I have a string that holds a value in the format of ddMMyyhhmmss.

Example 240512024707

I need to be able to convert this date to a real .NET Date object.

I am currently using CDate but it seems CDate does not recognize the format, is there any way of specifying the string format to CDate ???

row.Item("NoteDate") = CDate(n.noteText.Substring(0, 12).ToString).ToString("dd/MM/yyyy hh:mm:ss")

您有日期的字符串,你知道确切的格式字符串-使用DateTime.ParseExact (或DateTime.TryParseExact如果你想避免潜在引发异常):

DateTime.ParseExact("240512024707", "ddMMyyhhmmss", CultureInfo.InvariantCulture)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM