Using iText7 and documentinfo.GetMoreInfo("ModDate"), I get the following date string:
D:20220817113241+00'00'
How do I parse this in VB.NET?
Using iText7 and documentinfo.GetMoreInfo("ModDate"), I get the following date string:
D:20220817113241+00'00'
How do I parse this in VB.NET?
With the help of the comments, I found a solution:
Initial date string:
D:20220817113241+00'00'
If string starts with "D:", remove it.
20220817113241+00'00'
If a string has a +, remove the part beginning with the +.
20220817113241
Use a full format string like this:
yyyyMMddHHmmsszzz
Now measure the length of the remaining date string.
For example:
Dim s As String = "D:20220817113241+00'00'"
Dim sFormat As String = "yyyyMMddHHmmsszzz"
Dim iLen As Integer = s.Length
sFormat = Mid(sFormat, 0, iLen)
This makes the format string as long as the date string and cuts off anything that is not present in the date string, like "zzz".
Now use that format string like this:
Dim yourDate = DateTime.ParseExact(s, sFormat, Nothing)