I'm having the following data:
"startAt": "PT0S", "endAt": "PT21M12.667S"
startAt defines the start of a video and endAt the end of the video. How can I calculate the time between these points? I guess its ISO 8601 and I am using Java, but the library I tried (Joda) doens't work with the endAt paramter.
These are ISO-8601 period values (not points in time) - and Joda Time handles them fine:
import org.joda.time.*;
import org.joda.time.format.*;
public class Test {
public static void main(String[] args) {
String startText = "PT0S";
String endText = "PT21M12.667S";
PeriodFormatter format = ISOPeriodFormat.standard();
Period start = format.parsePeriod(startText);
Period end = format.parsePeriod(endText);
Duration duration = end.minus(start).toStandardDuration();
System.out.println(duration); // PT1272.667S
System.out.println(duration.getMillis()); // 1272667
}
}
See more on this question at Stackoverflow