Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...