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

CronBuilder: support java.time.Duration #427

Open
cdalexndr opened this issue May 10, 2020 · 9 comments
Open

CronBuilder: support java.time.Duration #427

cdalexndr opened this issue May 10, 2020 · 9 comments

Comments

@cdalexndr
Copy link

cdalexndr commented May 10, 2020

Construct a cron from java.time.Duration

@jmrozanec
Copy link
Owner

@cdalexndr may you elaborate a bit more on this?

@cdalexndr
Copy link
Author

cdalexndr commented May 10, 2020

My use case is that I want to use a single constant value that is used as a Duration for cache expiry and also as a cron job for regular cache repopulation. So I need some method to convert from a constant Duration to cron (the inverse is not be possible for any cron).

CronBuilder is using manual definition of each cron field.
My suggestion is for it to support parsing a Duration and auto-complete it's fields.

Example mappings:
Duration.ofSeconds(10) = 0/10 0 0 ? * *
Duration.ofHours(3) = 0 0 */3 ? * *
Duration.ofDays(2) = 0 0 0 */2 * ?

@cdalexndr
Copy link
Author

cdalexndr commented May 10, 2020

It seems that some values cannot be mapped correctly, so only simple durations should be accepted.
Duration.ofDays(2).plusHours(3) = ?

As there is not an universal conversion, this feature doesn't sound as good now so it's remains at your discretion.

@jmrozanec
Copy link
Owner

@cdalexndr thank you for the details. We will have a more detailed look at the use case and decide if we can provide a good solution for it. Best! 😄

@adwsingh
Copy link

adwsingh commented Oct 1, 2020

Hey I would like to take this up as a part of Hacktober fest.

@jmrozanec
Copy link
Owner

@MehWhatever sure! Thanks!

@jmrozanec
Copy link
Owner

@MehWhatever do we have any updates on this? Thanks!

@jmrozanec
Copy link
Owner

@MehWhatever do we have some update on this? Thanks!

@lsyldliu
Copy link

Does this have any progress?

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

4 participants