Professional Documents
Culture Documents
Finding Number of Days Between 2 Dates in JAVA
Finding Number of Days Between 2 Dates in JAVA
Date dt1=new Date(); // Date type variable dt1 declared Date dt2=new Date(); // Date type variable dt2 declared
String sd1=d1.getText(); // d1 is the name of the textfield that will accept start date in ddmm-yy format String sd2=d2.getText();// d2 is the name of the textfield that will accept end date in ddmm-yy format
try{ dt1=df.parse(sd1); // converting string sd1 to date type and storing in Date type variable dt1 dt2=df.parse(sd2); // converting string sd2 to date type and storing in Date type variable dt2 }catch(Exception e){}
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new zz4_dateDifference().setVisible(true); } }); }
// Variables declaration - do not modify private javax.swing.JTextField d1; private javax.swing.JTextField d2; private javax.swing.JTextField d3; private javax.swing.JButton jButton1; // End of variables declaration