mercredi 28 janvier 2015

Difference days of two dates


This code will compute the the total days between two dates using date chooser now my problem is the result gives me a negative number, the number is correct but it is in negative form, how to put it in positive form


private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:



Date date1 = this.dcStart.getDate();
Date date2 = this.dcRetire.getDate();
int minutes = 1000 * 60;
int hours = minutes * 60;
long days1 = hours * 24;
long years = days1 * 365;

long days = date1.getTime() - date2.getTime();
long DATE = days / days1;

txtWD.setText(Float.toString((float) DATE));

}




Aucun commentaire:

Enregistrer un commentaire