Atefeh Rashidi Atefeh Rashidi - 7 months ago 56
C# Question

How to get timeStamp in java like this code in C#

How can I re-write the code below (that is written in C#), in java to get same result?

TimeSpan Now = DateTime.UtcNow.Subtract(new DateTime(1970,1, 1));
long TimeStamp = Convert.ToInt64(Math.Floor(Now.TotalMilliseconds));

I want to translate the C# code to java language to get the value of TimeStamp (long variable).


Just use:

long timestamp = System.currentTimeMillis();