CSharp examples for System:TimeSpan
Formats the given time-span using the typical date-time formatting string.
/******************************************************************** * FulcrumWeb RAD Framework - Fulcrum of your business * * Copyright (c) 2002-2010 FulcrumWeb, ALL RIGHTS RESERVED * * * * THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED * * FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE * * COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE * * AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT * * AND PERMISSION FROM FULCRUMWEB. CONSULT THE END USER LICENSE * * AGREEMENT FOR INFORMATION ON ADDITIONAL RESTRICTIONS. * ********************************************************************/ using System.Globalization; using System;//from w ww.j a v a 2 s .c om public class Main{ //------------------------------------------------------------------------- /// <summary> /// Formats the given time-span using the typical date-time formatting string. /// </summary> /// <returns>formatted string</returns> static public string FormatTimespan(TimeSpan timespan, string format) { var now = DateTime.Now; var date = new DateTime(now.Year, now.Month, now.Day).Add(timespan); return date.ToString(format); } }