java date long -> C# datetime long:
TimeSpan ts = TimeSpan.FromMilliseconds(javaNum);
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
DateTime dateTime2 = dateTime.Add(ts);
DateTime final = dateTime2.ToUniversalTime(); // Change to local-time
C # -> java long
private static DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long CurrentTimeMillis()
{
return (long) (DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
No comments:
Post a Comment