It seems like you are trying to parse and format a JodaTime Period. You should not do it using the String class API. Use appropriate formatter already provided in JodaTime API.
You should build 2 PeriodFormatters using PeriodFormatterBuilder class, one for parsing the given string into a Period, and then second for formatting the Period to the required format:
String periodString = "PT14H01M00S";
PeriodFormatter parser = new PeriodFormatterBuilder()
.appendLiteral("PT")
.appendHours().appendSuffix("H")
.appendMinutes().appendSuffix("M")
.appendSeconds().appendSuffix("S")
.toFormatter();
PeriodFormatter formatter = new PeriodFormatterBuilder()
.minimumPrintedDigits(2)
.printZeroAlways()
.appendHours()
.appendSeparator(":")
.appendMinutes()
.appendSeparator(":")
.appendSeconds()
.toFormatter();
System.out.println(formatter.print(parser.parsePeriod(periodString)));
Output:
14:01:00