Skip to main content Link Search Menu Expand Document (external link)


MonthDay class from java.time.MonthDay can be used in rules for month-date related logic. Notable Methods:

constructorm, dCreates a MonthDay object with the given m and d keywords
parseStringCreates a MonthDay object with a given time string. The format is [--]M-d. Both the month and the date can be a one or two digit number, and optionally prefixed with --
now Creates a MonthDay object that represents the current month-day
ofmonth, dayCreates a MonthDay with the given month and day
month_value Returns the month part of the object as a number between 1 and 12
month Returns the month part of the object as java.time.Month enum
day_of_month Returns the second part of the object

For a full list of methods supported by MonthDay, please see the link above.

A MonthDay object can be compared against another MonthDay object or a parseable string representation of month-day.


#Different ways of creating a MonthDay object
now =
end_of_june = MonthDay.of(6, 30)
new_year = 1, d: 1)
halloween = MonthDay.parse('10-31')

if now > end_of_june # comparing two MonthDay objects
  # do something
elsif now < '03-05' # comparison against a string representation for March 5th
  #do something
elsif now == new_year
  #Happy new year!
elsif now == halloween
  #turn on spooky automation


between creates a MonthDay range that can be used to check if another MonthDay is within that range."Within month-day range") if between('02-20'..'06-01').cover?


when between('01-01'..'03-31')"First quarter")
when between('04-01'..'06-30')"Second quarter")