Header Ads

Create Employee Management System using JAVA - Part 13

Display Time and Date In  java Netbeans

















Right click on the menu bar add select 'Add Menu' as follows. There are two menu items Date & Time, I have listed.

Add this code to Employee_info.java

public void CurrentDate(){
        Calendar cal = new GregorianCalendar();
        int month = cal.get(Calendar.MONTH);
        int year = cal.get(Calendar.YEAR);
        int day = cal.get(Calendar.DAY_OF_MONTH);
        date_txt.setText("Date-"+year+"/"+(month+1)+"/"+day); // current date
        
        int second = cal.get(Calendar.SECOND);
        int minute = cal.get(Calendar.MINUTE);
        int hour = cal.get(Calendar.HOUR);
        time_txt.setText("Time-"+hour+":"+minute+":"+second); // current time
    }

public Employee_info() {
        initComponents();
        conn = javaconnect.ConnecrDb();
        Update_table();
        Fillcombo();
        CurrentDate(); // Date & Time
    }

See you on next tutorial 14 - How to Insert-Save data from netbeans java into database Sqlite (MySql) 

No comments

Thank you very much for your ideas!