How to convert UTC Date Time String to Java object and compare it ?

Use java.time.Instant;


import java.time.Instant;

Instant instantStart = Instant.parse("20200229T12:00:00Z");
Instant instantEnd = Instant.parse("20200329T12:00:00Z");
Instant instantNow = Instant.now();

return instantNow.isAfter(instantStart) &&  
       instantNow.isBefore(instantEnd);

Subscribe to Post, Code and Quiet Time.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe