Calendar calendar = GregorianCalendar.getInstance(); calendar.set(Calendar.MONTH, 2);//mois de mars calendar.set(Calendar.DAY_OF_MONTH, 1); SimpleDateFormat format = new SimpleDateFormat("dd MMMM yyyy"); System.out.println(format.format(calendar.getTime())); calendar.add(Calendar.DAY_OF_MONTH, -1);//on enlève un jour pour passer au dernier jour du mois précédent System.out.println(format.format(calendar.getTime())); System.out.println("il y a " + calendar.get(Calendar.DAY_OF_MONTH) + " jours");
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question