Skip to content
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

Closed
nrktkt opened this issue Jun 15, 2017 · 6 comments
Closed

Parse TemporalAmounts besides Duration #473

nrktkt opened this issue Jun 15, 2017 · 6 comments

Comments

@nrktkt
Copy link
Contributor

nrktkt commented Jun 15, 2017

The config currently has a handy method getDuration which parses readable strings like "5 minutes" into a java.time.Duration.

It would be nice if there was also a way to parse other TemporalAmounts such as Period ("2 years").

@havocp
Copy link
Collaborator

havocp commented Jun 25, 2017

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.
Thanks!

@nrktkt
Copy link
Contributor Author

nrktkt commented Jun 26, 2017

@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.

@havocp
Copy link
Collaborator

havocp commented Jun 28, 2017

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.

@nrktkt
Copy link
Contributor Author

nrktkt commented Jul 2, 2017

@havocp is there a reason the compiler targets java 6 source even though java 8 classes like Duration are already being used? (I was looking to use default methods in interfaces and string switches)

nrktkt added a commit to nrktkt/config that referenced this issue Jul 2, 2017
nrktkt added a commit to nrktkt/config that referenced this issue Jul 2, 2017
@havocp
Copy link
Collaborator

havocp commented Jul 2, 2017

I don't remember why that is; suggest digging up the PR discussion when we switched to java 8.

@2m 2m added this to the 1.3.2 milestone Oct 6, 2017
@2m
Copy link
Contributor

2m commented Oct 6, 2017

Implemented in #478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants