I want to parse a string like 1d2h3m4s into a java.time.Duration. I can use a joda's PeriodFormatter to parse the string into a org.joda.time.Duration but I can't figure out how to convert that to a standard Java8's java.time.Duration.
I have to interface to some "legacy" code that already expects java.time.Duration as input, but I want to use joda's parsePeriod because the java.time.Duration.parse() only accepts ISO-8601 duration format (1d2h3m4s is not ISO-8601 duration compliant)
import org.joda.time.format.PeriodFormatter;
import org.joda.time.format.PeriodFormatterBuilder;
...
final PeriodFormatter periodFormatter = new PeriodFormatterBuilder()
.printZeroNever()
.appendDays().appendSuffix("d")
.appendHours().appendSuffix("h")
.appendMinutes().appendSuffix("m")
.appendSeconds().appendSuffix("s").toFormatter();
org.joda.time.Duration myduration = periodFormatter.parsePeriod("1d1s").toStandardDuration();
java.util.time myduration2 = XXXXX
Please bear in mind that I'm not trying to remove the usage of org.joda.time.Period from my code like in Converting org.joda.time.Period to java.time.Period. I still want to have a org.joda.time.Period because I have more parsing option to generate those, and I need a java.time.Period/java.time.Duration because I interact with some other API/libraries that expect java.time.*.
So, is there a way to convert a org.joda.time.Duration to a java.time.Duration?