How to get milliseconds using java.time.instant

import java.time.Instant;

public class Main {
    public static void main(String[] args) {
        Instant now = Instant.now();

        // Get milliseconds from the epoch
        long milliseconds = now.toEpochMilli();

        System.out.println(milliseconds);
    }
}

Output: 1532444400000