Java tutorial
/* * The MIT License * * Copyright 2014 RBC1B. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package uk.org.rbc1b.roms.db.volunteer.interview; import java.io.Serializable; import java.util.Date; import org.hibernate.envers.Audited; import org.joda.time.DateTime; import org.joda.time.LocalDate; import uk.org.rbc1b.roms.controller.common.DataConverterUtil; import uk.org.rbc1b.roms.db.UpdateAuditable; import uk.org.rbc1b.roms.db.kingdomhall.KingdomHall; /** * A volunteer interview session, capturing where an d when a volunteer was interviewed. */ @Audited public class InterviewSession implements UpdateAuditable, Serializable { private static final long serialVersionUID = -3691787079284953169L; private Integer interviewSessionId; private KingdomHall kingdomHall; private java.sql.Date date; private String time; private String comments; private Date updateTime; private Integer updatedBy; /** * @return true if the session isin the past. */ public boolean isInPast() { DateTime today = LocalDate.now().toDateTimeAtStartOfDay(); DateTime sessionDate = DataConverterUtil.toDateTime(date); return today.isAfter(sessionDate); } /** * @return true if the session is today. */ public boolean isToday() { DateTime today = LocalDate.now().toDateTimeAtStartOfDay(); DateTime sessionDate = DataConverterUtil.toDateTime(date); return today.isEqual(sessionDate.toDateMidnight()); } public Integer getInterviewSessionId() { return interviewSessionId; } public void setInterviewSessionId(Integer interviewSessionId) { this.interviewSessionId = interviewSessionId; } public KingdomHall getKingdomHall() { return kingdomHall; } public void setKingdomHall(KingdomHall kingdomHall) { this.kingdomHall = kingdomHall; } public java.sql.Date getDate() { return date; } public void setDate(java.sql.Date date) { this.date = date; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public String getComments() { return comments; } public void setComments(String comments) { this.comments = comments; } @Override public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } @Override public Integer getUpdatedBy() { return updatedBy; } public void setUpdatedBy(Integer updatedBy) { this.updatedBy = updatedBy; } @Override public String toString() { return "InterviewSession #" + interviewSessionId; } }