0

如何将字符串格式 CCYYMMDD(即 20120624)的日期转换为 MM/DD/YYYY(即 06/24/2012)?

我正在尝试,但它没有解析,抛出异常 jDate is not a valid datetime format

Public Shared Function ConvertJDateToDate(ByVal jDate As String) As String
        Dim d As Date = Date.ParseExact("yyyyMMdd", jDate, CultureInfo.InvariantCulture)
        Dim newText As String = d.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture)
        Return newText
    End Function
4

1 回答 1

6

你的论点顺序错误。

你要这个:

Dim d As Date = DateTime.ParseExact( jDate, "yyyyMMdd", CultureInfo.InvariantCulture )
于 2013-10-22T18:38:52.540 回答