Jump to content
xisto Community
Sign in to follow this  
shanker7

Log In

Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.