-
Notifications
You must be signed in to change notification settings - Fork 966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse TemporalAmounts besides Duration #473
Comments
If this supports the same units as duration (maybe adds months?) I think it would be pretty straightforward to add a getPeriod method, and I don't see a reason not to do so. The approach I'd take would be to find everywhere that has duration now and add this along the same pattern. If there are any new units added, HOCON.md would need to be updated to reflect that. |
@havocp it would add days, weeks, months, and years. If you have any pointers for places to start I can look into throwing together a PR. |
I'd essentially look at getDuration and copy that; it should have unit tests to copy also. This is a fairly "surface level" feature of the library (conversion from string or number to duration/period is late-binding when someone calls getDuration) so you wouldn't need to touch the parser or other lower level stuff afaik. |
@havocp is there a reason the compiler targets java 6 source even though java 8 classes like |
I don't remember why that is; suggest digging up the PR discussion when we switched to java 8. |
Implemented in #478 |
The config currently has a handy method
getDuration
which parses readable strings like "5 minutes" into ajava.time.Duration
.It would be nice if there was also a way to parse other
TemporalAmount
s such asPeriod
("2 years").The text was updated successfully, but these errors were encountered: