/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.time.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String input
= "00:10:17" ; // Ambiguously looks like time-of-day but is actually intended as a span-of-time. Duration d = Duration.between( LocalTime.MIN , LocalTime.parse( input ) ) ;
long milliseconds = d.toMillis() ;
System.
out.
println( "input: " + input
); // TIP: Avoid the HH:MM:SS format for durations (spans of time). Instead use standard ISO 8601 format seen in this next line: PT10M17S
System.
out.
println( "d.toString(): " + d
); System.
out.
println( "milliseconds: " + milliseconds
);
// FYI, `Duration` class can directly parse standard ISO 8601 duration strings.
Duration dParsed = Duration.parse( "PT8H30M" ); // Eight and a half hour duration.
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgppbXBvcnQgamF2YS50aW1lLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoKICAgIFN0cmluZyBpbnB1dCA9ICIwMDoxMDoxNyIgOyAgLy8gQW1iaWd1b3VzbHkgbG9va3MgbGlrZSB0aW1lLW9mLWRheSBidXQgaXMgYWN0dWFsbHkgaW50ZW5kZWQgYXMgYSBzcGFuLW9mLXRpbWUuCiAgICBEdXJhdGlvbiBkID0gRHVyYXRpb24uYmV0d2VlbiggTG9jYWxUaW1lLk1JTiAsIExvY2FsVGltZS5wYXJzZSggaW5wdXQgKSApIDsKICAgIGxvbmcgbWlsbGlzZWNvbmRzID0gZC50b01pbGx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