Informational note for all: 

You are talking about javax.xml.datatype.Duration, not java.time.Duration.

Your questions:

a) Is there a quicker way to do this (using Java-8)? Hardly. The designers of JSR-310-team responsible for the new date- and time library in Java-8 have not cared much about the bridge to the existing XML-classes in JDK. So there is no direct way to convert from xml-duration to any kind of JSR-310-duration.

Keep also in mind that the JSR-310-classes Period (with state consisting of years, months and days) and Duration (with state consisting of seconds and nanoseconds) are not really designed for representing an xml-duration (which has more units as seen in your code). So I doubt if we might see a well-defined bridge between JSR-310 and XML in the future (maybe only on millisecond base?). The sign handling is also completely different in JSR-310 and XML. So be cautious if you have negative sign in xml-duration.

b) Is there a cleaner way to do this (using Java-8)? Yes, a little bit. One thing to consider is: I would use the clock as time source for the actual instant only once and not twice as you have done it. Example for this (very) minor improvement:

Instant now = Instant.now();
LocalDateTime start = now.atOffset(ZoneOffset.UTC).toLocalDateTime();
LocalDateTime end = 
  start.plusYears(duration.getYears())
  .plusMonths(duration.getMonths())
  .plusDays(duration.getDays())
  .plusHours(duration.getHours())
  .plusMinutes(duration.getMinutes())
  .plusSeconds(duration.getSeconds());
long deltaInMillis = end.toInstant(ZoneOffset.UTC).toEpochMilli() - now.toEpochMilli();


Second thing to consider: The xml-duration class is designed for interoperation with java.util.Date. So you also have this short alternative:

Date start = new Date();
long deltaInMillis = duration.getTimeInMillis(start);


This alternative is not only much shorter, but is probably also more precise because it takes into account the millisecond part. According to the documentation you should only worry about the correctness if you have duration items in long range (excessing the range of int). Another topic is the relationship to any hidden timezone calculation. I have not seen any hint in the documentation, so this is maybe the only item which can make you worry (either local timezone? or UTC? - not tested).

c) Why worry about large durations? Even if your duration is larger than let's say some centuries possibly crossing the validity limits of historic gregorian calendar, you should keep in mind that xml-duration only uses the proleptic gregorian calendar, not the historical one. And LocalDateTime uses the same proleptic gregorian calendar, too. If such a large duration is related to any real data is another good question however.

Java 8 -- How do I calculate (milli)seconds from now using xsd:duration
I encountered device made by Texas Instruments with label USB2ANY HPA665. It has LED, mini USB and FloppyDiskDrive-like ports.

I can't find any data-sheet, manual or resources what for and how to use this device. Looks like some kind of programmer/debugger? Can anyone help?

It has MSP430 microcontroller.



More pictures here.
