I\'d like to produce Partials from Strings, but can\'t find anything in the API that supports that. Obviously, I can write my own parser outside of the Joda-Time framework
You have to start by defining the valid format for Partials which you will be accepting. There is no class which will just take text and infer the best possible match for a Partial. It's way too subjective based on locale, user preference, etc. So there's no way of getting around making a list of all of the valid formats for input. It will be very difficult to make these all mutually exclusive for each other, so there should be priorities. For example, you might want mm/dd
and mm/yy
to both be valid formats. If I give you the string 02/11
, which one should have priority?
Once you've determined exactly the valid formats, you should use DateTimeFormat.forPattern
to create a DateTimeFormatter
for each one. Then you can use each formatter to try to parseInto
a MutableDateTime
. Then, go through each field in the MutableDateTime
and transfer the value into a Partial
.
Unfortunately, there is no better way to handle this in the Joda library.