javat mills<-> C# DateTime

LIN-KEITH
LIN-KEITH
Aug 25, 2017 · 1 min read
using System;namespace imorevWebApi.Factory {
public class TimeUtils {
public static long toJavaMills(DateTime ? input) {
var time = DateTime.Now;
if (input != null) {
time = (DateTime) input;
}
var time1 = new DateTime(1970, 1, 1, 0, 0, 0);
var t = Convert.ToInt64(time.ToUniversalTime().Subtract(time1).TotalMilliseconds);
return t;
}
public static DateTime millsToDateTime(long javaMS){var UTCBaseTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);var dt = UTCBaseTime.Add(new TimeSpan(javaMS * TimeSpan.TicksPerMillisecond)).ToLocalTime();
return dt;
}
}
}
)
LIN-KEITH

Written by

LIN-KEITH

Android dev

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade