001    package org.nakedobjects.applib.fixtures;
002    
003    /**
004     * Sole purpose is to set the date/time while object fixtures are being installed.
005     * 
006     * <p>
007     * An alternative is to change the date using {@link AbstractFixture#setDate(int, int, int)} and
008     * {@link AbstractFixture#setTime(int, int)}.
009     * 
010     * <p>
011     * Note that the last date set <i>will</i> remain in force for the application itself.  To revert to the
012     * current time, have a fixture at the end call {@link #resetClock()}.
013     * 
014     * @see SwitchUserFixture
015     */
016    public class DateFixture extends AbstractFixture {
017    
018        public DateFixture(final int year, final int month, final int day, final int hour, final int minutes) {
019            this.year = year;
020            this.month = month;
021            this.day = day;
022            this.hour = hour;
023            this.minute = minutes;
024        }
025    
026        public DateFixture(final int year, final int month, final int day) {
027            this(year, month, day, 0, 0);
028        }
029    
030        private final int year;
031    
032        public int getYear() {
033            return year;
034        }
035        private final int month;
036    
037        public int getMonth() {
038            return month;
039        }
040        private final int day;
041    
042        public int getDay() {
043            return day;
044        }
045        private final int hour;
046    
047        public int getHour() {
048            return hour;
049        }
050        private final int minute;
051    
052        public int getMinute() {
053            return minute;
054        }
055    
056        @Override
057        public void install() {
058            setDate(year, month, day);
059            setTime(hour, minute);
060        }
061    
062    }