mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-01-12 13:01:10 +00:00
Remove dependency with joda time to simplify the project dependencies
This commit is contained in:
parent
4d90e7e394
commit
a9b6565fcf
6 changed files with 35 additions and 61 deletions
|
|
@ -15,11 +15,9 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -30,12 +28,14 @@ import javax.persistence.ManyToOne;
|
|||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Simple business object representing a pet.
|
||||
|
|
@ -49,9 +49,9 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||
public class Pet extends NamedEntity {
|
||||
|
||||
@Column(name = "birth_date")
|
||||
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
|
||||
@Temporal(TemporalType.DATE)
|
||||
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
||||
private LocalDate birthDate;
|
||||
private Date birthDate;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "type_id")
|
||||
|
|
@ -64,12 +64,13 @@ public class Pet extends NamedEntity {
|
|||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
|
||||
private Set<Visit> visits;
|
||||
|
||||
public LocalDate getBirthDate() {
|
||||
return this.birthDate;
|
||||
|
||||
public void setBirthDate(Date birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public void setBirthDate(LocalDate birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
public Date getBirthDate() {
|
||||
return this.birthDate;
|
||||
}
|
||||
|
||||
public PetType getType() {
|
||||
|
|
|
|||
|
|
@ -15,16 +15,17 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.model;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing a visit.
|
||||
|
|
@ -39,9 +40,9 @@ public class Visit extends BaseEntity {
|
|||
* Holds value of property date.
|
||||
*/
|
||||
@Column(name = "visit_date")
|
||||
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
||||
private LocalDate date;
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* Holds value of property description.
|
||||
|
|
@ -62,7 +63,7 @@ public class Visit extends BaseEntity {
|
|||
* Creates a new instance of Visit for the current date
|
||||
*/
|
||||
public Visit() {
|
||||
this.date = new LocalDate();
|
||||
this.date = new Date();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ public class Visit extends BaseEntity {
|
|||
*
|
||||
* @return Value of property date.
|
||||
*/
|
||||
public LocalDate getDate() {
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ public class Visit extends BaseEntity {
|
|||
*
|
||||
* @param date New value of property date.
|
||||
*/
|
||||
public void setDate(LocalDate date) {
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue