CSharp examples for System:DateTime Convert
Converts Java Date to Local Time
using System.Web; using System.Text.RegularExpressions; using System.Globalization; using System.Extensions; using System.Web.Mvc; using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System.Collections; using System;/* w w w. j a v a 2s.c o m*/ public class Main{ /// <summary> /// Converts JavaDate to Local Time /// </summary> /// <param name="javaTimeStamp">The java time stamp.</param> /// <returns></returns> public static DateTime JavaTimeStampToDateTime(this long javaTimeStamp) { // Java timestamp is millisecods past epoch System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); dtDateTime = dtDateTime.AddSeconds(Math.Round((double)javaTimeStamp / 1000)).ToLocalTime(); return dtDateTime; } /// <summary> /// Converts JavaDate to Local Time /// </summary> /// <param name="javaTimeStamp">The java time stamp.</param> /// <returns></returns> public static DateTime JavaTimeStampToDateTime(this double javaTimeStamp) { // Java timestamp is millisecods past epoch System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); dtDateTime = dtDateTime.AddSeconds(Math.Round(javaTimeStamp / 1000)).ToLocalTime(); return dtDateTime; } }