Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

("21-10-2010" "31-10-2010") it is in string and tell me how to calculate days between these two dates in java?

user-image
Question ajoutée par Gourav sen gourav
Date de publication: 2014/08/12
Kayvan Tehrani
par Kayvan Tehrani , Senior Software Engineer , British Petroleum

static final long MILLI_SECONDS_IN_A_DAY =1000 *60 *60 *24;

static final String DATE_FORMAT = "dd-MM-yyyy";

public long daysBetween(String fromDateStr, String toDateStr) throws ParseException {  

SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);

Date fromDate;

Date toDate;

fromDate = format.parse(fromDateStr);

toDate = format.parse(toDateStr);

return (toDate.getTime() - fromDate.getTime()) / MILLI_SECONDS_IN_A_DAY; 

   }

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?