java.lang.Object
de.powerstat.validation.values.MonthDay
- All Implemented Interfaces:
IValueObject
,Comparable<MonthDay>
DayMonth.
Not DSGVO relevant.
TODO LeapYear support
TODO min, max
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd months to this MonthDay.int
Compare with another object.dayValue()
Returns the day value of this DayMonth.Decrement this MonthDay by one month.boolean
Is equal with another object.int
hashCode()
Calculate hash code.Increment this MonthDay by one month.Returns the month value of this DayMonth.static MonthDay
DayMonth factory.static MonthDay
DayMonth factory.Returns the String value of this DayMonth in ISO8601 format.Subtract months from this MonthDay.toString()
Returns the string representation of this DayMonth.
-
Field Details
-
OVERFLOW
Overflow constant.- See Also:
-
UNDERFLOW
Underflow constant.- See Also:
-
DATE_SEP
Date separator.- See Also:
-
month
Month. -
day
Day.
-
-
Constructor Details
-
MonthDay
Constructor.- Parameters:
month
- Monthday
- Day- Throws:
NullPointerException
- When month or day is nullIndexOutOfBoundsException
- When the day is less than 1 or greater than 31 or the day is to large for the month.IllegalStateException
- When the month is in an illegal state
-
-
Method Details
-
of
DayMonth factory.- Parameters:
month
- Month 1-12day
- Day 1-31- Returns:
- DayMonth object
-
of
DayMonth factory.- Parameters:
value
- ISO8601 format [m]m-[d]d- Returns:
- DayMonth object
-
monthValue
Returns the month value of this DayMonth.- Returns:
- The month value represented by this object.
-
dayValue
Returns the day value of this DayMonth.- Returns:
- The day value represented by this object.
-
stringValue
Returns the String value of this DayMonth in ISO8601 format.- Specified by:
stringValue
in interfaceIValueObject
- Returns:
- The String value represented by this object ([m]m-[d]d).
-
hashCode
public int hashCode()Calculate hash code. -
equals
Is equal with another object. -
toString
Returns the string representation of this DayMonth. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "DayMonth[month=1, day=1]" -
compareTo
Compare with another object.- Specified by:
compareTo
in interfaceComparable<MonthDay>
- Parameters:
obj
- Object to compare with- Returns:
- 0: equal; 1: greater; -1: smaller
- See Also:
-
add
Add months to this MonthDay.- Parameters:
months
- Months to add to this MonthDay- Returns:
- New MonthDay after adding the months to this MonthDay
- Throws:
ArithmeticException
- In case of an overflow
-
subtract
Subtract months from this MonthDay.- Parameters:
months
- Months to subtract from this MonthDay- Returns:
- New MonthDay after subtracting months from this MonthDay
- Throws:
ArithmeticException
- In case of an underflow
-
incrementMonth
Increment this MonthDay by one month.- Returns:
- New MonthDay after incrementing this MonthDay by one month
- Throws:
ArithmeticException
- In case of an overflow
-
decrementMonth
Decrement this MonthDay by one month.- Returns:
- New MonthDay after decrement this MonthDay by one month
- Throws:
ArithmeticException
- In case of an overflow
-