Parsing Joda-Time Partials

前端 未结 3 1469
难免孤独
难免孤独 2021-01-18 14:49

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

3条回答
  •  别那么骄傲
    2021-01-18 15:06

    I've extended DateTimeParserBucket. My extended class intercepts calls to the saveField() methods, and stores the field type and value before delegating to super. I've also implemented a method that uses those stored field values to create a Partial.

    I'm able to pass my bucket instance to DateTimeParser.parseInto(), and then ask it to create the Partial.

    It works, but I can't say I'm impressed with Joda-Time - given that it doesn't support parsing Partials out of the box. The lack of DateTimeFormatter.parsePartial(String) is a glaring omission.

提交回复
热议问题