Atefeh Rashidi Atefeh Rashidi - 1 year ago 127
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).

Answer Source

Just use:

long timestamp = System.currentTimeMillis();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download