TL; DR
Instant.parse( "2014-10-23T00:35:14.800Z" ) .toEpochMilli()
One liner in java.time
The java.time framework is built into Java 8 and later. These new classes replace the older time classes associated with the earliest versions of Java, such as java.util.Date/.Calendar. See Tutorial . The java.time classes also supplant the very successful Joda-Time library, which is built by some of the same people, including those led by the same Stephen Colborn .
An Instant is a moment in the UTC timeline with a nanosecond resolution. You can ask him for the number of milliseconds from epoch (the first moment of 1970 in UTC ). But remember that Instant may have additional data, nanoseconds smaller than milliseconds. Thus, you can lose data in this small fraction of a second.
The java.time classes use standard ISO 8601 formats for parsing / generating strings. There is no need to specify a formatting template. The Instant class can directly parse a string .
Instant.parse( "2014-10-23T00:35:14.800Z" )
You can convert this value to milliseconds from the first moment of 1970 in UTC by calling toEpochMilli
Be aware of potential data loss, as the Instant class can hold nanoseconds. Thus, extracting milliseconds will truncate any microseconds or nanoseconds in any fractional second. The line in your example contains only three digits in a fractional second, so this is just milliseconds. But six or nine digits of the decimal fraction will be truncated to three when they are converted to the number of milliseconds.
long millisFromEpoch = Instant.parse( "2014-10-23T00:35:14.800Z" ).toEpochMilli();
To get the elapsed time in hours-minutes-seconds, use the Duration class. Feed it between method of a pair of points in time.
Duration duration = Duration.between( Instant.parse( "2014-10-23T00:35:14.800Z" ) , Instant.now() );
One liner in Yoda time
UPDATE: The Joda-Time project is in maintenance mode, and the team advises switching to the java.time classes.
With Joda-Time Library 2.5:
long millisSinceEpoch = new DateTime( "2014-10-23T00:35:14.800Z" ).getMillis();
Joda-Time parses and generates ISO 8601 strings by default. Joda-Time runs on Android. The java.util.Date/.Calendar classes are known to be unpleasant, confusing, and erroneous. Avoid them.