How can I get the number of days in a year using JodaTime?
问题 I've tried the following to no avail: new Period(Years.ONE).getDays(); new Period(1, 0, 0, 000).getDays(); The answer I want is obviously 365. 回答1: If you want the real number of days for a given year: int year = 2012; LocalDate ld = new LocalDate(year,1,1); System.out.println(Days.daysBetween(ld,ld.plusYears(1)).getDays()); Of course, this returns 365 or 366... normally: int year = 1582; LocalDate ld = new LocalDate(year,1,1,GJChronology.getInstance()); System.out.println(Days.daysBetween(ld