javadatetimemilliseconds

How can I get the current milliseconds from the current time


Note, I do NOT want millis from epoch. I want the number of milliseconds currently on the clock.

So for example, I have this bit of code.

Date date2 = new Date(); 
Long time2 = (long) (((((date2.getHours() * 60) + date2.getMinutes())* 60 ) + date2.getSeconds()) * 1000);

Is there a way to get milliseconds with date? Is there another way to do this?

Note: System.currentTimeMillis() gives me millis from epoch which is not what I'm looking for.


Solution

  • 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.