We have made this class as immutable:
- The class is final. That means no subclasses can be created. A subclass of an immutable class can be made mutable again. As noted above, an attacker could use that to get to confidential data.
- The variables are all final and cannot be changed after construction
- In the constructor we use the
import org.joda.time.DateTimeclass. This is a better version than the
java.util.Datebecause it is immutable. Using a
java.util.Datewould be dangerous as it is a mutable class and we can’t control the calling thread (which might modify it).
- There are no setter methods for the members.