How to compare two java.time.Period in java 8?
问题 How do I compare two Periods in java 8? E.g. Period one = Period.of(10,0,0); Period two = Period.of(8,0,0); here in this case one is greater than two. 回答1: It is true that the comparison of two Period objects does not make sense in a general case, due to the undefined standard length of a month. However, in many situations you can quite well live with an implementation similar to that which follows. The contract will be similar to the contract of compareTo() : public int