UPDATE: Instant has nothing to do with UTC in the timezone sense. It is related to UTC as a time standard only.

The major difference is the return type. They have different String representations because the types themselves have very different meanings.

Instant#now(Clock) returns Instant. An Instant is "[a]n instantaneous point on the time-line".

LocalDate#now(Clock) returns LocalDate. A LocalTime is "a description of the local time as seen on a wall clock".

As a result Instant#now(Clock) and LocalDate#now(Clock) mean very different things and naturally have different outcomes. The major thing they have in common is a name. Method names are dust. Refer to the types.

On a fixed Clock, both Instant.now(clock) and LocalDate.now(clock) will return constant values. The point of accepting Clock as a parameter is to be able to control things like the reference time or clock resolution.

Answer from Alain O'Dea on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › time › Clock.html
Clock (Java Platform SE 8 )
4 days ago - The returned instants from Clock work on a time-scale that ignores leap seconds, as described in Instant. If the implementation wraps a source that provides leap second information, then a mechanism should be used to "smooth" the leap second. The Java Time-Scale mandates the use of UTC-SLS, ...
Discussions

New java time api ? (Date vs Instant)
Hello everyone, I would like to know if it is planned or discussed to add/replace the use of Date java object by the new Instant java class. For example, from AbsoluteDate, there is method to obtain a Date object (precision at 1 millisecond) whereas the Instant, from new java time api, is precise ... More on forum.orekit.org
🌐 forum.orekit.org
0
0
April 26, 2021
java - Which one is recommended: Instant.now().toEpochMilli() or System.currentTimeMillis() - Stack Overflow
In Java, we can have many different ways to get the current timestamp, For current timestamp just use Instant.now(). More on stackoverflow.com
🌐 stackoverflow.com
July 10, 2021
Has the precision of Instant.now changed in Java 17?
It has happened in Java 15: https://bugs.openjdk.org/browse/JDK-8242504 More on reddit.com
🌐 r/java
31
72
September 13, 2024
Rely on Instant.now instead of System.currentTimeMillis() inside of Clock
At the moment, Clock[F].realTime is platform-independent and relies on System.currecurrentTimeMillis(). It means, that the maximum precision for getting wall-clock time is limited to milliseconds. I'd suggest having a JVM-specific implementation that relies on java.time.Instant.now() instead, ... More on github.com
🌐 github.com
7
November 28, 2020
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › time › Instant.html
Instant (Java Platform SE 8 )
4 days ago - The exact boundary between the two segments is the instant where UT1 = UTC between 1972-11-03T00:00 and 1972-11-04T12:00. Implementations of the Java time-scale using the JSR-310 API are not required to provide any clock that is sub-second accurate, or that progresses monotonically or smoothly.
🌐
Baeldung
baeldung.com › home › java › java dates › guide to the java clock class
Guide to the Java Clock Class | Baeldung
August 19, 2025 - If the duration is negative, then the resulting clock instant will be earlier than the given base clock.
🌐
Orekit
forum.orekit.org › orekit usage
New java time api ? (Date vs Instant) - Orekit usage - Orekit
April 26, 2021 - Hello everyone, I would like to know if it is planned or discussed to add/replace the use of Date java object by the new Instant java class. For example, from AbsoluteDate, there is method to obtain a Date object (precision at 1 millisecond) whereas the Instant, from new java time api, is precise at 1 nanosecond.
🌐
TutorialsPoint
tutorialspoint.com › javatime › javatime_clock_instant.htm
java.time.Clock.instant() Method Example
September 13, 2024 - The java.time.Clock.instant() method gets the current instant of the clock. Following is the declaration for java.time.Clock.instant() method. public int instant() the current instant from this clock, not null. DateTimeException − if the instant cannot be obtained, not thrown by most ...
🌐
Blogger
mattgreencroft.blogspot.com › 2014 › 12 › java-8-time-choosing-right-object.html
Matt Greencroft's Blog: Java 8 Time - choosing the right object
January 10, 2018 - But my clock operates on LocalDateTime (or it would if it were running Java) – if I had an InstantClock it would have looked like this: 00:58 00:59 01:00 01:01 And if had a ZonedDateTime clock it might have looked like this: 01:58 BST 01:59 BST 01:00 GMT 01:01 GMT (BST stands for British Summer Time – it’s another way of saying GMT+1) Now let’s suppose we were writing code that was going to run a critical piece of functionality each night at 1.30am.
🌐
Baeldung
baeldung.com › home › java › java dates › difference between instant and localdatetime
Difference Between Instant and LocalDateTime | Baeldung
January 8, 2024 - We saw the Instant is just a negative or positive offset from the Unix epoch time and is always tied to the UTC time zone. We also saw that LocalDateTime is just a calendar and clock without any time zone information.
Find elsewhere
🌐
Saigon Technology
saigontechnology.com › home › blog › deep dive into java.time: instant
Deep dive into java.time: Instant - Saigon Technology
February 24, 2025 - In essence, Instant.now() provides a convenient way to access the current time with nanosecond precision (in theory). However, the underlying system might restrict the actual accuracy to milliseconds. Remember, this explanation is for educational purposes and might not reflect the exact implementation details in all Java environments.
Top answer
1 of 5
26

Both are fine. And neither is recommended except for a minority of purposes.

What do you need milliseconds since the epoch for?

In Java, we can have many different ways to get the current timestamp,

For current timestamp just use Instant.now(). No need to convert to milliseconds.

Many methods from the first years of Java, also many in the standard library, took a long number of milliseconds since the epoch as argument. However, today I would consider that old-fashioned. See if you can find — or create — or more modern method that takes for instance an Instant as argument instead. Go object-oriented and don’t use a primitive long. It will make your code clearer and more self-explanatory.

As Eliott Frisch said in a comment, if this is for measuring elapsed time, you may prefer the higher resolution of System.nanoTime().

If you do need milliseconds since the epoch

Assuming that you have good reasons for wanting a count of milliseconds since the epoch, …

which one is recommended: Instant.now().toEpochMilli() or System.currentTimeMillis()[?]

Opinions differ. Some will say that you should use java.time, the modern date and time API, for all of your date and time work. This would imply Instant here. Unsg java.time is generally a good habit since the date and time classes from Java 1.0 and 1.1 (Date, Calendar, TimeZone, DateFormat, SimpleDateFormat and others) are poorly designed and now long outdated, certainly not any that we should use anymore. On the other hand I am not aware of any design problem with System.curremtTimeMillis() in particular (except what I mentioned above about using a long count of milliseconds at all, which obviously is intrinsic to both Instant.now().toEpochMilli() and System.currentTimeMillis()).

If there is a slight performance difference between the two, I have a hard time imagining the situation where this will matter.

Take the option that you find more readable and less surprising in your context.

Similar questions

  • JSR 310 :: System.currentTimeMillis() vs Instant.toEpochMilli() :: TimeZone
  • Java current time different values in api
2 of 5
7

I want to add that System.nanoTime() is less about precision but more about accuracy.

System.currentTimeMillis() is based on the system clock, which is, most of the time, based on a quartz clock inside a computer. It is not accurate and it drifts. (VM is even worse since you don't have a physical clock and have to sync with the host) When your computer syncs this quartz clock with a global clock, you might even observe your clock jumps backward/forward because your local clock is too fast or slow.

On the other hand, System.nanoTime() is based on a monotonic clock. This clock has nothing to do with the actual time we humans speak. It only moves forward at a constant pace. It does not drift like the quartz clock and there is no sync required. This is why it is perfect for measuring elapses.

🌐
Oracle
docs.oracle.com › en › java › javase › 26 › docs › api › java.base › java › time › Instant.html
Instant (Java SE 26 & JDK 26)
October 20, 2025 - The exact boundary between the two segments is the instant where UT1 = UTC between 1972-11-03T00:00 and 1972-11-04T12:00. Implementations of the Java time-scale using the JSR-310 API are not required to provide any clock that is sub-second accurate, or that progresses monotonically or smoothly.
🌐
Reddit
reddit.com › r/java › has the precision of instant.now changed in java 17?
r/java on Reddit: Has the precision of Instant.now changed in Java 17?
September 13, 2024 -

I'm just upgrading a project from Java 11 to Java 21 and found that Instant.now() has greater precision now since Java 17. Previously, it was microseconds and now it is nanoseconds.

This is reasonable as the Javadoc does say the precision is system dependent. Unfortunately, this makes the upgrade less trivial for us as this extra precision causes issues with some databases, and some clients of our API.

I can't find anything in the release notes and want to confirm that:

  • This is actually a change due to my upgrade and not some other factor I haven't realized

  • There isn't a flag that I can use to activate the previous behaviour

I'm a bit paranoid because I don't see why this wouldn't have occurred with Java 11 also but it seems to me that upgrading past Java 17 reliably reproduces the behaviour, on the same exact system.

Otherwise, I think I will need to wrap this method and truncate it in order to get back the previous behavior as I cannot update all of the clients in a backwards compatible way.

🌐
Mincong Huang
mincong.io › 2020 › 05 › 24 › java-clock
Controlling Time with Java Clock - Mincong Huang
May 24, 2020 - This article is written in Java 11, but most of the concepts should be available since Java 8. A fixed clock is a clock that always returns the same instant. It freezes the world at a fixed moment.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-8-clock-instant-method-with-examples
Java 8 Clock instant() method with Examples - GeeksforGeeks
April 14, 2023 - The Java Date Time API was added from Java version 8. instant() method of Clock class returns a current instant of Clock object as Instant Class Object. Instant generates a timestamp to represent machine time.
🌐
GitHub
github.com › typelevel › cats-effect › issues › 1460
Rely on Instant.now instead of System.currentTimeMillis() inside of Clock · Issue #1460 · typelevel/cats-effect
November 28, 2020 - At the moment, Clock[F].realTime is platform-independent and relies on System.currecurrentTimeMillis(). It means, that the maximum precision for getting wall-clock time is limited to milliseconds. I'd suggest having a JVM-specific implementation that relies on java.time.Instant.now() instead, as starting from Java 9 it's up to the nanoseconds precise time resolution.
Author   sergeykolbasov
🌐
ConcretePage
concretepage.com › java › java-8 › java-clock
Java Clock Class
Instant is an instantaneous point on time line. instant() returns current Instant defined by the clock. Find the usage. package com.concretepage; import java.time.Clock; import java.time.Instant; public class InstantExample { public static void ...
🌐
Medium
medium.com › @willchinelato › the-difference-between-instant-and-date-time-52fac96c64ab
The Difference Between Instant and Date/Time | Medium
April 16, 2025 - During a training about the Java date/time API (java.time), I created a story to demonstrate the difference between instant and date/time.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › time › Clock.html
Clock (Java SE 17 & JDK 17)
October 20, 2025 - The returned instants from Clock work on a time-scale that ignores leap seconds, as described in Instant. If the implementation wraps a source that provides leap second information, then a mechanism should be used to "smooth" the leap second. The Java Time-Scale mandates the use of UTC-SLS, ...
🌐
Android Developers
developer.android.com › api reference › instant
Instant | API reference | Android Developers
January 10, 2026 - Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体