From long with 6 millisecond digits(YYYY-MM-DD HH:MM:SS[.uuuuuu].) - CSharp System

CSharp examples for System:DateTime Second

Description

From long with 6 millisecond digits(YYYY-MM-DD HH:MM:SS[.uuuuuu].)

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  ww w  . j a v  a 2s  .c om*/

public class Main{
        /// <summary>
        /// From long with 6 millisecond digits(YYYY-MM-DD HH:MM:SS[.uuuuuu].)
        /// </summary>
        public static DateTimeOffset FromBigQueryTimestamp(this ulong timestamp)
        {
            var seconds = Math.Round(((double)timestamp / 1000));
            var date = unixEpochOffset.AddMilliseconds(seconds);
            return date;
        }
        /// <summary>
        /// From long with 6 millisecond digits(YYYY-MM-DD HH:MM:SS[.uuuuuu].)
        /// </summary>
        public static DateTimeOffset FromBigQueryTimestamp(this long timestamp)
        {
            var seconds = Math.Round(((double)timestamp / 1000));
            var date = unixEpochOffset.AddMilliseconds(seconds);
            return date;
        }
}

Related Tutorials