Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Java Program to get Milliseconds between two time instants

import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
public class Demo {
	public static void main(String[] args) {
		Instant time1 = Instant.now();
		Instant time2 = time1.plus(5, ChronoUnit.HOURS).plus(50, ChronoUnit.SECONDS);
		Duration duration = Duration.ofSeconds(13);
		Instant i = time1.plus(duration);
		System.out.println("Milliseconds between two time instants = "+ChronoUnit.MILLIS.between(time1, time2));
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.