EstimatedSettlementDate.java
package com.tradecloud.domain.model.deal;
import org.hibernate.annotations.Type;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
@Embeddable
public class EstimatedSettlementDate implements Serializable {
@Transient
DateTimeFormatter dayOfWeekfromatter = DateTimeFormat.forPattern("E");
@Column(name = "estimated_settlement_date")
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
private LocalDate localDate;
public EstimatedSettlementDate() {
}
private EstimatedSettlementDate(LocalDate localDate) {
this.localDate = localDate;
}
public static EstimatedSettlementDate getInstance(LocalDate localDate) {
return new EstimatedSettlementDate(localDate);
}
public EstimatedSettlementDate plusDays(int numberOfDays) {
return new EstimatedSettlementDate(localDate.plusDays(numberOfDays));
}
public LocalDate getLocalDate() {
return new LocalDate(localDate);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof EstimatedSettlementDate)) {
return false;
}
EstimatedSettlementDate that = (EstimatedSettlementDate) o;
if (!localDate.equals(that.localDate)) {
return false;
}
return true;
}
@Override
public String toString() {
return "EstimatedSettlementDate{" +
"localDate=" + localDate +
'}';
}
@Override
public int hashCode() {
return localDate.hashCode();
}
public static EstimatedSettlementDate getInstance(Date estimatedSettlementDate) {
return new EstimatedSettlementDate(LocalDate.fromDateFields(estimatedSettlementDate));
}
}