Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a library for time interval composition in Java or Scala? [closed]

I am looking for a library for Java or Scala allowing boolean composition of time intervals, to define periods like "Monday to Friday except 23:00—23:20 UTC". Something like crontab interval definition, but with arbitrary compositions allowed. Is there anything like that?

like image 625
Alexander Temerev Avatar asked Mar 31 '11 11:03

Alexander Temerev


3 Answers

I don't know if there is something exactly like that, but as a base you could look at JODA Time, an extensive Java Library for all kinds of Date/Time handling.


EDIT:

i just remembered that the Play! Framework uses CRON expressions. It contains a CRON expression parser that may be useful to you:

https://github.com/playframework/play/blob/master/framework/src/play/libs/Time.java

Also it got this parser from Quartz, an open source job scheduler, that may also be of interest to you: http://www.quartz-scheduler.org/

like image 162
RoToRa Avatar answered Nov 07 '22 17:11

RoToRa


Well, it's joda-time, not joda-date, but it definitely has interval mechanisms - so you'd be down to parsing the interval formats you're interested in.

Note also that Stephen has a new project, based on JSR-310, called "threeten" - see http://threeten.sourceforge.net/.

like image 3
Joseph Ottinger Avatar answered Nov 07 '22 19:11

Joseph Ottinger


There are Scala wrapper for Joda Time and scala-datetime, a ongoing implementation of JSR-310.

like image 4
pedrofurla Avatar answered Nov 07 '22 17:11

pedrofurla