Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
380 views
in Technique[技术] by (71.8m points)

date - How to get DateTimePicker value and could throw true if its value will be empty in java

I was trying to make an if and else statement that will not accept the process if the DateTimePicker was empty so I tried this one but it is just ignoring it so any possible way how can I get the value or text from this DateTime picker?

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    if(dateTimePicker1.equals("") || dateTimePicker2.equals("") || jTextField1.getText().equals("PACKAGES OFFERED: ") 
            || jTextField5.getText().equals("FOOD SERVICES: ") || jTextField6.getText().equals("HOTEL ACTIVITIES: ")
            || jTextField7.getText().equals("HOTEL SERVICES: "))
    {

        jLabel8.setText("Invalid data please add valid data");
        jLabel8.setOpaque(true);
    }
    else{
        Hotel_Dashboard2 hd1 = new Hotel_Dashboard2();
        Hotel_Dashboard2.jLabel8.setText(Hotel_Dashboard1.jLabel9.getText());
        hd1.setVisible(true);
        

    }
}  

Here are the code that I tried:

if(dateTimePicker1=='' || dateTimePicker2.=='' 
if(dateTimePicker1.length===(0) || dateTimePicker2.length===(0)
if(dateTimePicker1==null || dateTimePicker2.equals==null
 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...