Not going to lie really wish I could create a couple new methods inside Java.time.localdate right now and have it become an actual part of the downloadable jvm & jdk
@crazyuncleharris Of course, you would need to deliver your code for others to use it.
π€
... which is perhaps what was the most important in your case.
πΆ
@paercebal localdate has functionality for comparing 2 dates to be equal, before or after: isEqual(), isAfter(), isBefore() but no isLesser() or isGreater() after heavily having to chain theses methods together for a program to determine further execution I feel heavily that localDate could natively benefit from this.
@crazyuncleharris If I understand correctly, there is isAfter(), but not isGreater(), which is the standard way to compare other Java objects, is that right?
Yeah, this is a pain. If every object has its own specific methods for comparison, trying to remember them all is a mess.
@paercebal isEqual() is normally the "defacto" method to compare two objects to being the same. isAfter() and isBefore () is specific to the localDate (& probably LocalTime & LocalDateTime) classes
I believe a lot of classes contain the underlying function of compareTo() which returns 0(aka equals) or -1/1 for not equal
I created isGreaterEq(d1,d2) and isLessEq(d1,d2) and stuck it in one of our many many utility classes for transforming dates. But it would be nice to have it in localDate
@crazyuncleharris I hear you.
For what is worth, something like that can be done in C# with extension methods, and in C++ just by adding the new functions in the right namespace and including the new header (C++ favors functions over methods).
π€
I'm not sure Java has something like any solution above.
π€
Anyway, this is tricky, as this means you are trespassing inside someone else's namespace. In C#, it's mostly safe, while in C++ this is usually a big no-no (using ADL is preferred).
π€