require 'date' module Pact module Generator # Date provides the time generator which will give the current date in the defined format class Date def can_generate?(hash) hash.key?('type') && hash['type'] == type end def call(hash, _params = nil, _example_value = nil) format = hash['format'] || default_format ::Time.now.strftime(convert_from_java_simple_date_format(format)) end def type 'Date' end def default_format 'yyyy-MM-dd' end # Format for the pact specficiation should be the Java DateTimeFormmater # This tries to convert to something Ruby can format. def convert_from_java_simple_date_format(format) # Year format.sub!(/(?