How can I retrieve the current date and time from my system in Java without using predefined classes or libraries?


how can i fetch current date and time of my system in java without using any predefined classes or libraries? i am actually making a Date ADT of my own from scratch as java.util.Date or Java.util.Calendar. but i am not able to find out a way to fetch system date and time, say to calculate age of somebody if he enters his current age. in a way i want to learn how they developers of Date or Calendar class actually implemented it. is there a way that i can see the code of Date and Calendar classes defined in java.util package.

Using System.currentTimeMillis():

Returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

As for the source code of java.util.Date and java.util.Calendar, you can either download the source directly from, or view it online in or here.