The problem is that what you have is not a datetime. It is an interval. A datetime formatter is not going to be able to cope with it. The formatter APIs produce a Date
object (for the legacy DateFormat
classes) or a TemporalAccessor
object (for DateTimeFormatter
). There is no direct support for intervals in either the current or legacy Java date / time APIs.
Given that the format / formatter classes can't return an interval, it is not surprising that the format strings don't support this1.
So, the only alternative is to do some parsing / string bashing yourself. @Sun's answer is one solution.
1 - If you could write a format / formatter pattern that tell the parser to "ignore the next 5 characters" for example, you could create two different formatters that parsed your example to extract the first datetime and the second datetime. But you can't. One reason is that this approach would not work for formatting.