7. The DateManipulator Mutable Companion to Date.

Listing 7. The DateManipulator Mutable Companion to Date.


public class DateManipulator ...
{
    public synchronized void set(
        Year year, Month month, int day)
    {
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public synchronized Date toDate()
        { return new Date(year, month, day); }
    public int getYear() { return year.getValue(); }
    ...
    private Year year;
    private Month month;
    private int day;
}

About the Author

Kevlin Henney is a Principal Technologist with QA Training in the UK.