Convert Date String into Epoch in Java

Ashley picture Ashley · Apr 21, 2016 · Viewed 44.8k times · Source

Is there a way to convert a given Date String into Milliseconds (Epoch Long format) in java? Example : I want to convert

public static final String date = "04/28/2016"; 

into milliseconds (epoch).

Answer

Paul Ostrowski picture Paul Ostrowski · Apr 21, 2016

The getTime() method of the Date class returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.