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?

Re: C# equivalent of Java Calender class 80 80

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.

Re: C# equivalent of Java Calender class 80 80

This will get you started.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.