public Date calculDatePremEch(Date d){
try {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Date dateDeb=format.parse(format.format(d));
Calendar calendrier = new GregorianCalendar();
calendrier.setTime(dateDeb);
Calendar dernierDuMois = new GregorianCalendar (calendrier.get(Calendar.YEAR), calendrier.get(Calendar.MONTH), 1);
//passer au dernier jour du mois
dernierDuMois.add(dernierDuMois.MONTH, 1);
dernierDuMois.add(dernierDuMois.DAY_OF_MONTH, -1);
this.setDatePremEch(format.parse(format.format(dernierDuMois.getTime())));
this.setDateEch(format.parse(format.format(dernierDuMois.getTime())));
return format.parse(format.format(dernierDuMois.getTime()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
Partager