For my Java to C# conversion project, I need to use something equivalent to Java's Calender class. I have some codes like:

Calender cal = Calender.getInstance();
long time = Calendar.getInstance().getTime().getTime();
long time2 = System.currentTimeMillis();

which returns some random values at different times. I have come to know C-sharp's DateTime is the closest to this Calender class, but DateTime's Tick property does not give exactly the similar result.

What will be my required code snippet here to get my desired output?

3 Years
Discussion Span
Last Post by ddanbe

I have found a code snippet that solves the System.currentTimeMillis() method's purpose.

public static long CurrentTimeMillis()
    DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
    return (long) (DateTime.Now - Jan1st1970).TotalMilliseconds;

Still need help on Calender.getInstance() method, please help.

Edited by mesbahuk: adding a link

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.