Do you mean?

long millis = System.currentTimeMillis() % 1000;

BTW Windows doesn't allow timetravel to 1969

C:\> date
Enter the new date: (dd-mm-yy) 2/8/1969
The system cannot accept the date entered.
Answer from Peter Lawrey on Stack Overflow
🌐
Tutorialspoint
tutorialspoint.com › java › lang › system_currenttimemillis.htm
Java System currentTimeMillis() Method
Once loop is completed, we've again noted down the end time by getting the current time in milliseconds. package com.tutorialspoint; public class SystemDemo { public static void main(String[] args) throws InterruptedException { // start time of the code snippet long startTime = System.currentTimeMillis(); int sum = 0; // a time consuming task for (int i = 0; i < 10; i++) { // sleep for 100 ms Thread.sleep(100); sum += i; } // end time of the code snippet long endTime = System.currentTimeMillis(); System.out.println("Program took " + (endTime - startTime) + " ms") ; } }
🌐
BeginnersBook
beginnersbook.com › 2014 › 01 › how-to-get-time-in-milliseconds-in-java
Java – Get time in milliseconds using Date, Calendar and ZonedDateTime
2) Using public long getTimeInMillis() method of Calendar class 3) Java 8 – ZonedDateTime.now().toInstant().toEpochMilli() returns current time in milliseconds.
🌐
Current Millis
currentmillis.com › tutorials › system-currentTimeMillis.html
Unix Timestamp in Milliseconds
System.currentTimeMillis() - Unix Timestamps in Java & Javascript. Milliseconds & the Unix Epoch. UTC time
🌐
Baeldung
baeldung.com › home › java › java dates › convert time to milliseconds in java
Convert Time to Milliseconds in Java | Baeldung
May 2, 2019 - In this quick tutorial, we’ll illustrate multiple ways of converting time into Unix-epoch milliseconds in Java. ... We’ll use this value to initialize our various objects and verify our results. ... Calendar calendar = // implementation details Assert.assertEquals(millis, calendar.getTimeInMillis()); Simply put, Instant is a point in Java’s epoch timeline. We can get the current time in milliseconds from the Instant:
🌐
Javaprogramto
javaprogramto.com › 2020 › 12 › java-get-current-time-in-milliseconds.html
Java - Get Time In MilliSeconds JavaProgramTo.com
Current date : Sat Dec 12 21:48:25 ... 3925 Future date time in milliseconds : 61696501250000 · Next, use the Calendar class to get the time in milli seconds....
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Java - Get Time In MilliSeconds - Java Code Geeks
December 17, 2020 - Current date : Sat Dec 12 21:48:25 ... 3925 Future date time in milliseconds : 61696501250000 · Next, use the Calendar class to get the time in milli seconds....
🌐
javaspring
javaspring.net › blog › java-get-current-time-in-milliseconds
Java: Get Current Time in Milliseconds — javaspring.net
In this example, we record the start time and end time using System.currentTimeMillis(), and then calculate the difference to get the execution time of the loop. When logging events in an application, it is often useful to include a timestamp. We can use the current time in milliseconds for this purpose. import java.util.logging.Level; import java.util.logging.Logger; public class LoggingWithTimestamp { private static final Logger LOGGER = Logger.getLogger(LoggingWithTimestamp.class.getName()); public static void main(String[] args) { long currentTime = System.currentTimeMillis(); LOGGER.log(Level.INFO, "[" + currentTime + "] This is a log entry."); } }
Find elsewhere
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.javasystem.currenttimemillis
JavaSystem.CurrentTimeMillis Method (Java.Lang) | Microsoft Learn
Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-8-clock-millis-method-with-examples
Java 8 Clock millis() Method with Examples - GeeksforGeeks
June 17, 2021 - Code: Clock clock = Clock.syst... returns a current instant of Class Object in milliseconds. Below programs illustrates millis() method of java.time.Clock class: Program 1: Using millis() with Clock object created with ...
Top answer
1 of 3
3

tl;dr

Duration.between( todayStart , now ).toMillis()

Details

Get the current moment in the wall-clock time used by the people of a certain region (a time zone).

ZoneId z = ZoneId.of( “Africa/Tunis” ) ;
ZonedDateTime now = ZonedDateTime.now( z ) ;

Get the first moment of the day. Do not assume this is 00:00:00. Let java.time determine.

ZonedDateTime todayStart = now.toLocalDate().atStartOfDay( z ) ;

Represent the delta between them, the span of time unattached to the timeline, as a Duration.

Duration d = Duration.between( todayStart , now ) ;

A Duration has a resolution of nanoseconds. That is finer than the milliseconds you desire. A convenience method will ignore any microseconds or nanoseconds for you.

long millisSinceStartOfToday = d.toMillis() ;

About java.time

The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date, Calendar, & SimpleDateFormat.

The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.

To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.

You may exchange java.time objects directly with your database. Use a JDBC driver compliant with JDBC 4.2 or later. No need for strings, no need for java.sql.* classes.

Where to obtain the java.time classes?

  • Java SE 8, Java SE 9, and later
    • Built-in.
    • Part of the standard Java API with a bundled implementation.
    • Java 9 adds some minor features and fixes.
  • Java SE 6 and Java SE 7
    • Much of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport.
  • Android
    • Later versions of Android bundle implementations of the java.time classes.
    • For earlier Android (<26), the ThreeTenABP project adapts ThreeTen-Backport (mentioned above). See How to use ThreeTenABP….

The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval, YearWeek, YearQuarter, and more.

2 of 3
3

Use the LocalTime class:

long millis = LocalTime.now().toNanoOfDay() / 1_000_000;

Basil Bourque correctly points out that it isn’t always this simple: a Daylight Saving Time change (such as will occur in most of the US this Sunday) can mean that, for example, there may not be eight hours between midnight and 8 AM.

You can account for this by using a ZonedDateTime, which accounts for all calendar information, including DST changeovers:

ZonedDateTime now = ZonedDateTime.now();
ZonedDateTime start = now.truncatedTo(ChronoUnit.DAYS);
long millis = ChronoUnit.MILLIS.between(start, now);
🌐
TutorialsPoint
tutorialspoint.com › how-to-get-current-date-time-in-milli-seconds-in-java
How to get current date/time in milli seconds in Java?
The getTime() method of the Date class retrieves and returns the epoch time (number of milliseconds from Jan 1st 1970 00:00:00 GMT0. ... import java.util.Date; public class Sample { public static void main(String args[]){ //Instantiating the Date class Date date = new Date(); long msec = ...
🌐
Mkyong
mkyong.com › home › java › how to get time in milliseconds in java
How to get time in milliseconds in Java - Mkyong.com
January 22, 2015 - package com.mkyong.test; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class TimeMilisecond { public static void main(String[] argv) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"); String dateInString = "22-01-2015 10:20:56"; Date date = sdf.parse(dateInString); System.out.println(dateInString); System.out.println("Date - Time in milliseconds : " + date.getTime()); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); System.out.println("Calender - Time in milliseconds : " + calendar.getTimeInMillis()); } }
🌐
JavaBeat
javabeat.net › home › how to get a current timestamp in java?
How to Get a Current Timestamp in Java?
May 6, 2024 - We can invoke the constructor of ... //Converting Current Timestamp in Milliseconds System.out.println("The Current Timestamp in Milliseconds == " + currentTS.getTime()); } }...
🌐
Baeldung
baeldung.com › home › java › java dates › get the current date and time in java
Get the Current Date and Time in Java | Baeldung
January 8, 2024 - To get the current time in milliseconds since the Unix epoch (January 1, 1970, 00:00:00 GMT), we can use the currentTimeMillis() method: long elapsedMilliseconds = System.currentTimeMillis(); For higher precision, we can use System.nanoTime() ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-system-currenttimemillis-method-with-examples
Java.lang.System.currentTimeMillis() Method with Examples - GeeksforGeeks
July 23, 2025 - ... // Java Program to illustrate TimeMillis() Method // Importing input output classes import java.io.*; // Main Class class GFG { // Main driver method public static void main(String[] args) { // Note: Whenever the program is run // outputs ...
🌐
Educative
educative.io › answers › what-is-currenttimemillis-in-java
What is currentTimeMillis() in Java?
The static currentTimeMillis() method from the java.lang.System class is used to get the current program execution time in milliseconds. The millisecond will be returned as a unit of time.
🌐
BeginnersBook
beginnersbook.com › 2017 › 10 › java-time-in-milliseconds-format
Java – Display current time in Milliseconds Format
import java.util.Calendar; import ... class Date date = new Date(); //Pattern for showing milliseconds in the time "SSS" DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String stringDate = sdf.format(date); System.out.println(stringDate); //Using Calendar ...