I found a bug. It was necessary, according to some logic, to obtain a time interval, and without being tied to specific dates, that is, just a wrapper around the number of milliseconds between certain events.
In my code, I calculated startDate and endDate, and returned Duration like this:
return new Period(startDate, endDate).toDuration();
It turned out that if startDate and endDate were separated from each other by more than a month, JodaTime threw an exception. The solution was found quickly:
')
return new Interval(startDate, endDate).toDuration();
I fixed it and wondered why I made such a blunder. JodaTime has a very rich set of classes for describing everything related to time, and I had no time to understand the difference between Period, Interval, Duration, etc. And very vain.
When I wrote the code, it turned in my head "during the reporting period, the grain growers of the Kuban were removed and thrashed ....". I, although I speak fluent English, chose the first class I got that was similar to the “reporting period”, i.e. Period.
Why am I all this? By the importance of correctly naming your classes / methods / variables. I read (on time, aha, after I finished the project) the documentation for JodaTime and envied me with white envy. The guys made a lot of effort to make each class a necessary noun. Interval is not a Period, and it's understandable why (yeah, now it's clear). Unfortunately, this is not always the case with me. It's a pity.