CSharp examples for System:DateTime Format
convert it to string with "ddMMyyyy" format. If it's null, return an empty string
using System.Web; using System.Linq; using System.Collections.Generic; using System;/*from w ww . j av a2s. com*/ public class Main{ /// <summary> ///for nullable datetime variables. /// If the date is non null, convert it to string with "dd/MM/yyyy" format. If it's null, return an empty string /// </summary> public static string PaceConvertDateToUkDateString(this DateTime? input) { if (input != null) { return (Convert.ToDateTime(input)).ToString("dd/MM/yyyy"); } else { return ""; } } }