Skip to content
Youngho Chaa cha cha

Java Instant Class

java, Instant1 min read

Instant class is like a single moment in time in the UTC time zone. If time is a line, Instant represents a single point on the line. It's Unix epoch time based.


Instant twelveHoursFromNow =, ChronoUnit.HOURS);
Instant thirtyDaysAgo = instantSource.instant().minus(30, ChronoUnit.DAYS);
Instant oneWeekAgo =, ChronoUnit.DAYS);

We can compare two Instants

Instant instant1 =;
Instant instant2 =, ChronoUnit.SECONDS);
© 2024 by Youngho Chaa cha cha. All rights reserved.
Theme by LekoArts