I have the following problem.
In a class I declare:
vulnerabilityDetailsTable.AddCell(new PdfPCell(new Phrase(currentVuln.Published.ToString(), _fontNormale)) { Border = PdfPCell.NO_BORDER, Padding = 5, MinimumHeight = 30, PaddingTop = 10 });
and the interesting part is: currentVuln.Published.ToString(). This work fine.
Published is a DateTime property declared as nullable, in this way:
public System.DateTime? Published { get; set; }
The problem is that in the previous way the printed value of currentVuln.Published.ToString() is something like 18/07/2014 00:00:00 (also the time is included in the date).
I want show only the date and not show the time so I tryed to use something like it:
currentVuln.Published.ToShortDateString()
But it don't work and I obtain the following error message in Visual Studio:
Error 4 'System.Nullable<System.DateTime>' does not contain a definition for 'ToShortDateString' and no extension method 'ToShortDateString' accepting a first argument of type 'System.Nullable<System.DateTime>' could be found (are you missing a using directive or an assembly reference?) C:\Develop\EarlyWarning\public\Implementazione\Ver2\PdfReport\PdfVulnerability.cs 93 101 PdfReport
It seems that this happen because my DateTime field is nullable.
What am i missing? How can I fix this issue?