fork download
  1. import java.time.Duration;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. System.out.println(durationToMillis("10:00"));
  6. }
  7.  
  8. static long durationToMillis(String strDuration) {
  9. String[] arr = strDuration.split(":");
  10. Duration duration = Duration.ZERO;
  11. if (arr.length == 2) {
  12. strDuration = "PT" + arr[0] + "M" + arr[1] + "S";
  13. duration = Duration.parse(strDuration);
  14. }
  15. return duration.toMillis();
  16. }
  17. }
Success #stdin #stdout 0.16s 51940KB
stdin
Standard input is empty
stdout
600000