Load the Current Date and Time in Java


This tutorial is about how to Load Current Date/Time Using Java. This tutorial will help you on how to load the system current date and time through label element in Java. The program will display the current date and time base from the computer system.

Some of the computer systems are using the date and time to track and identify the program transactions. The program includes Point of Sale System, Inventory System, Billing System and much more.

Load Current Date/Time Using Java

1.Create/Add a new JFrame Form inside your source package.

2. Design your Form just like what I do in the image below.

3. Add the following import codes above your class to access the required libraries.

[java]import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;[/java]

4. Create a new method inside your class.

[java]public final void loadDateTime(){


5. Insert the following codes inside your new created method.

[java]//load date/time
Date date = GregorianCalendar.getInstance().getTime();
Date time = GregorianCalendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat(“MMMM dd, yyyy”);
SimpleDateFormat sdf2 = new SimpleDateFormat(“HH:mm:ss”);

6. Copy the method name and insert it into your public method inside your class.

[java]public LoadSystemDateTime() {

7. Run your program and the output should look like the image below.

Remember that the computer system date and time will be displayed in the program you created whether it is updated or outdated. If you have comments and question about Load Current Date/Time Using Java. Feel free to use our contact information.

Related Articles You May Like:

If you find this article useful, you can share this to your friends.

Looking for more source code? Type your keyword here here!



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.