How to express "never" with java.util.Date?

coding-style, date, java

Solution

well never is never, not the 1/1/2999.

I would stay with your 1st solution. a Null date means it has not yet happened.

maybe you can wrap it with something like :

boolean isNeverDeleted(){
    return deletionDate == null;
}

Problem

I have a class with the fields "deletionDate" and "experiationDate" which could both be undefined, what would mean that the object is whether deleted nor has an expiration date. My first approach was: ``` private Date deletionDate = null; // null means not deleted ``` Having the book "Clean Code" in mind I remember to better use expressive names instead of comments. So my current solutions is: ``` private static final Date NEVER = null; private Date deletionDate = NEVER; ``` I could user a wrapper class around Date, but that would complicate JPA mapping. What do you think of it? How would you express "never"?

Original source