java - JodaTime - Number of days in each months between 2 dates -


i have 2 dates :

datetime startingdate = new datetime(starting_year, starting_month, starting_day, 0, 0); datetime endingdate = new datetime(ending_year, ending_month, ending_day, 0, 0);  total_days = days.daysbetween(startingdate, endingdate).getdays(); 

it easy know total days between, i'm not familiar @ api , know if there easier way find number of days in each months between 2 dates without loops , ifs.

example :

datetime startingdate = new datetime(2000, 1, 1, 0, 0); datetime endingdate = new datetime(2000, 2, 3, 0, 0); 

would give 31 january , 2 february.

thanks!

i did loop finally.

datetime startingdate = new datetime(starting_year, starting_month, starting_day, 0, 0); datetime endingdate = new datetime(ending_year, ending_month, ending_day, 0, 0); total_days = days.daysbetween(startingdate, endingdate).getdays();  datetime currentdate = startingdate;  system.out.println(currentdate.dayofmonth().getmaximumvalue() - currentdate.dayofmonth().get() + 1); currentdate = currentdate.plus(period.months(1));  while (currentdate.isbefore(endingdate)) {       system.out.println(currentdate.dayofmonth().getmaximumvalue());      currentdate = currentdate.plus(period.months(1));  }   system.out.println(endingdate.dayofmonth().get()); 

Comments