Method return date in format dd.mm.yyy - CSharp System

CSharp examples for System:DateTime Format

Description

Method return date in format dd.mm.yyy

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  ww w . java2 s.  c om*/

public class Main{
        /// <summary>
		/// Method return date in format dd.mm.yyy
		/// </summary>
		/// <param name="date"></param>
		/// <returns></returns>
		public static string GetDateDottedStringFormat(this DateTime date) {
			var day = date.Day < 10 ? String.Format("0{0}", date.Day) : date.Day.ToString();
			var month = date.Month < 10 ? String.Format("0{0}", date.Month) : date.Month.ToString();

			return String.Format("{0}.{1}.{2}", day, month, date.Year);
		}
}

Related Tutorials