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(){
}[/java]
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”);
jLabel2.setText(sdf2.format(time));
jLabel1.setText(sdf.format(date));[/java]
6. Copy the method name and insert it into your public method inside your class.
[java]public LoadSystemDateTime() {
initComponents();
loadDateTime();
}[/java]
7. Run your program and the output should look like the image below.
About The Load the Current Date and Time In Java
Project Name: | Load the Current Date and Time |
Language/s Used: | JAVA |
Database: | None |
Type: | Desktop Application |
Developer: | IT SOURCECODE |
Updates: | 0 |
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:
- Clear Text Field Element in Java
- Load Image from Path to JLabel in Java
- Display Text Field Value to Another Text Field in Java
- Save Data to MySQL in Java using Netbeans
- Create MySQL Connection in Java
- How to Play MP3 Music in Java
If you find this article useful, you can share this to your friends.
Very good article post.Thanks Again. Keep writing.
Yes we will be posting more JAVA Projects with Source Code this month.