Close

Java Date Time - Instant.toEpochMilli() Examples

Java Date Time Java Java API 


Class:

java.time.Instant

java.lang.Objectjava.lang.Objectjava.time.Instantjava.time.Instantjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public long toEpochMilli()
Returns the number of milliseconds from the epoch of 1970-01-01T00:00:00Z of this Instant object.

Examples


package com.logicbig.example.instant;

import java.time.Instant;

public class ToEpochMilliExample {

public static void main(String... args) {
Instant i = Instant.now();
System.out.println(i);

long l = i.toEpochMilli();
System.out.println(l);
}
}

Output

2017-05-01T20:57:05.833Z
1493672225833




See Also