Parsing time strings like “1h 30min”

前端 未结 6 718
遇见更好的自我
遇见更好的自我 2020-11-29 07:28

Anyone know of a Java library that can parse time strings such as \"30min\" or \"2h 15min\" or \"2d 15h 30min\" as milliseconds (or some kind of Duration object). Can Joda-T

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 07:55

    No, Joda defaults to taking only Durations, Instant intervals, and objects. For the latter it accepts things like Dates or SOAP ISO format. You can add you own converter here for the Duration class, and admittedly that would hide all your ugly code.

提交回复
热议问题