shanker7 0 Report post Posted June 30, 2011 Hi,Friends this is shanker...Can anybody please post me the java code which can store the system time when click on some button... Share this post Link to post Share on other sites
k_nitin_r 8 Report post Posted August 24, 2011 You ought to look up the Java API documentation to learn to do this. According to the API documentation, the java.util.Date constructor "initializes it so that it represents the time at which it was allocated," which means that you can do something like this: java.util.Date dt1 = new java.util.Date();Put the constructor call in an action handler for a button, declare the variable as a member variable of the class, and if you need to display the date anywhere, call the toString() method on the date object. If you want to have more control over how the date is displayed, take a look at the java.text.DateFormat class and, more specifically, the format method of the DateFormat class. You can also build the date string by obtaining the date parts using the java.util.Calendar class. The Calendar.get method takes a parameter that you can specify as "java.text.Calendar." followed by DAY_OF_MONTH, MONTH, YEAR, HOUR_OF_DAY, MINUTE, SECOND.Use the auto-complete of your Java IDE to help you with finding the other methods for the Date and Calendar classes. Share this post Link to post Share on other sites