Think in terms of objects, not text. Date-time objects have their own internal implementations of the date-time values they represent. So tte have no “format” because that are not mere strings.
Parse your input text as an OffsetDateTime
using DateTimeFormatter
. This has been covered many many times already on Stack Overflow. Search to learn more.
From that OffsetDateTime
object, extract an Instant
.
Instant myInstant = myOffsetDateTime.toInstant() ;
Compare that Instant
with the current moment.
boolean isInThePast = myInstant.isBefore( Instant.now() ) ;
Notice that no text is involved. The objects do the heavy lifting for us, rather than us doing string manipulations and comparisons.