/// <summary> /// Converts the DateTime value to a short date string. /// </summary> /// <exception cref="ArgumentNullException">The format info can not be null.</exception> /// <param name="dateTime">The DateTime value to convert.</param> /// <param name="formatInfo">The date time format info.</param> /// <returns>The given value converted to a short date string.</returns> public static String ToShortDateString( this DateTime dateTime, DateTimeFormatInfo formatInfo ) { dateTime.ThrowIfNull( nameof( dateTime ) ); formatInfo.ThrowIfNull( nameof( formatInfo ) ); return dateTime.ToString( "d", formatInfo ); }
/// <summary> /// Converts the DateTime value to a universal sortable long date time string. /// </summary> /// <exception cref="ArgumentNullException">The format info can not be null.</exception> /// <param name="dateTime">The DateTime value to convert.</param> /// <param name="formatInfo">The date time format info.</param> /// <returns>The given value converted to a universal sortable long date time string.</returns> public static String ToUniversalSortableLongDateTimeString( this DateTime dateTime, DateTimeFormatInfo formatInfo ) { formatInfo.ThrowIfNull( nameof( formatInfo ) ); return dateTime.ToString( "U", formatInfo ); }
/// <summary> /// Converts the DateTime value to a full date time string. /// </summary> /// <exception cref="ArgumentNullException">The format info can not be null.</exception> /// <param name="dateTime">The DateTime value to convert.</param> /// <param name="formatInfo">The date time format info.</param> /// <returns>The given value converted to a full date time string.</returns> public static String ToFullDateTimeString( this DateTime dateTime, DateTimeFormatInfo formatInfo ) { formatInfo.ThrowIfNull( nameof( formatInfo ) ); return dateTime.ToString( "F", formatInfo ); }