1 package org.paneris.jammyjoes.controller; 2 3 import java.sql.Timestamp; 4 import java.util.Calendar; 5 import java.util.Date; 6 import java.util.GregorianCalendar; 7 8 import org.paneris.jammyjoes.mvp.DayAdaptor; 9 import org.paneris.jammyjoes.mvp.EquatableComparable; 10 import org.paneris.jammyjoes.mvp.TimesliceFactory; 11 12 public class DailyTimesliceFactory implements TimesliceFactory { 13 14 private final Date startDate; 15 16 public DailyTimesliceFactory(Date date) { 17 this.startDate = date; 18 } 19 20 public EquatableComparable create(Timestamp date) { 21 return new DayAdaptor(date); 22 } 23 24 public Date getStartDate() { 25 return startDate; 26 } 27 28 public Date getEndDate() { 29 Calendar calendar = asCalendar(); 30 calendar.add(Calendar.MONTH, 1); 31 return calendar.getTime(); 32 33 } 34 35 private Calendar asCalendar() { 36 return new GregorianCalendar(startDate.getYear()+1900,startDate.getMonth(), startDate.getDate()); 37 } 38 39 }