accounting: Accounting): Maybe[EndOfBillingState] = Maybe {
val billingMonthStartDate = new DateCalculator(yearOfBillingMonth, billingMonth, 1)
- val billingMonthStopDate = billingMonthStartDate.endOfThisMonth
+ val billingMonthStopDate = billingMonthStartDate.copy.endOfThisMonth
logger.debug("billingMonthStartDate = %s".format(billingMonthStartDate))
- logger.debug("billingMonthStartDate == billingMonthStopDate = %s".format(billingMonthStartDate == billingMonthStopDate))
logger.debug("billingMonthStopDate = %s".format(billingMonthStopDate))
val prevBillingMonthStartDate = billingMonthStartDate.previousMonth
/**
* Date calculator.
*
- * Utility class for date manipulations.
+ * Utility class for date manipulations. Not that this is mutable.
*
* @author Christos KK Loverdos <loverdos@gmail.com>
*/
-class DateCalculator private(private[this] var dateTime: MutableDateTime) {
+class DateCalculator private(private[this] var dateTime: MutableDateTime) extends Cloneable {
def this(millis: Long) = this(new MutableDateTime(millis))
def this(date: Date) = this(new MutableDateTime(date))
def this(cal: Calendar) = this(new MutableDateTime(cal))
def this(year: Int, monthOfYear: Int) =
this(year, monthOfYear, 1)
+
+ override def clone(): DateCalculator = new DateCalculator(this.dateTime)
+
+ def copy: DateCalculator = clone()
+
def plusMonths(n: Int): this.type = {
dateTime.addMonths(n)