Joda-Time solution (outdated)
You may not need those 6 decimals on the seconds in your result. You may want to consider that question again. The format you are asking for is ISO 8601. The ISO 8601 format does not dictate the number of decimals but leaves it to be agreed between the parties exchanging the data. Most implementations accept varying number of decimals (up to some limit, but providing fewer than the limit is no problem in the cases I have met).
The others are correct that you may very well consider upgrading to java.time, the successor of Joda-Time. In case you cannot afford to do that right now, here’s a way of obtaining the string that you want with Joda-Time.
String time = "124204";
String date = "05/09/25";
DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HHmmss");
DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("dd/MM/yy");
LocalTime lt = LocalTime.parse(time, timeFormatter);
LocalDate ld = LocalDate.parse(date, dateFormatter);
DateTime dateTime = ld.toLocalDateTime(lt).toDateTime(DateTimeZone.UTC);
DateTimeFormatter resultFormatter
= DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZZ");
String dateTimeString = dateTime.toString(resultFormatter);
System.out.println(dateTimeString);
Output:
2025-09-05T12:42:04.000000+00:00
I noticed that you asked for 2025-01-05T00:42:04.000000Z. Maybe you had not noticed that hour of day in your time string was 12 (not 00) and the month in your date string was 09 (not 01). In your own code you got incorrect hour and month because you used lower case pattern letters throughout in your format pattern. We need upper case HH for hour of day and upper case MM for month.
Edit: You also wanted Z rather than +00:00 to denote UTC (offset zero from UTC) like you get from the no-arg DateTime.toString(). Again ISO 8601 allows both, so it may not matter. I was surprised, though, not to find an easy way to get Z. The following formatter gives it, but I may be missing something simpler.
DateTimeFormatter resultFormatter = new DateTimeFormatterBuilder()
.append(ISODateTimeFormat.dateHourMinuteSecond())
.appendPattern(".SSSSSS")
.appendTimeZoneOffset("Z", true, 2, 2)
.toFormatter();
2025-09-05T12:42:04.000000Z
I have also used a different approach to parsing. While concatenating your two strings and parsing the result works, I find it clearer to parse each string separately.
As others have said, when you ask for a specific format, for example a specific number of decimals on the seconds, you can have that format only in a string. So the solution to that is to format your DateTime into a string.
Usage: A millisecond is a 1000th of a second. So asking for 6 digits of milliseconds does not make sense and would not give you higher precision. I took your question to mean 6 decimals of fraction of second — also known as microseconds (millionths of second).
Links