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 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).
πŸ€“

@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.

Follow

@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

Sign in to participate in the conversation

CounterSocial is the first Social Network Platform to take a zero-tolerance stance to hostile nations, bot accounts and trolls who are weaponizing OUR social media platforms and freedoms to engage in influence operations against us. And we're here to counter it.