cron expression parsing into java date

前端 未结 4 680
旧时难觅i
旧时难觅i 2021-02-08 02:38
  • my database having 10 18 16 ? * SUN,MON,WED,FRI * cron expression then how to convert into Java date.
  • how to comparing with present day time.
4条回答
  •  不要未来只要你来
    2021-02-08 03:05

    I wrote a small class for handling cron expressions, available here: https://github.com/frode-carlsen/cron

    Based on Joda-time, but should be fairly easy to port to Java8 time api. This also makes it possible to embed in unit tests, do simulations etc by adjusting the DateTime offset in Joda-time.

    It also has pretty good test coverage (was done as TDD Kata).

    Update Now supports java 8 time api as well thanks to a contribution from github user https://github.com/zemiak. In both cases, the expression parser is a single, tiny class which can easily be copied into your own project.

提交回复
热议问题