mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-25 03:42:48 +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
26
pom.xml
26
pom.xml
|
@ -21,11 +21,6 @@
|
|||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<docker.image.prefix>arey</docker.image.prefix>
|
||||
|
||||
<!-- Dates -->
|
||||
<jodatime-hibernate.version>1.3</jodatime-hibernate.version>
|
||||
<jodatime-jsptags.version>1.1.1</jodatime-jsptags.version>
|
||||
<jadira-usertype-core.version>5.0.0.GA</jadira-usertype-core.version>
|
||||
|
||||
<!-- Web dependencies -->
|
||||
<webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
|
||||
<webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
|
||||
|
@ -71,27 +66,6 @@
|
|||
<artifactId>jstl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Date and Time -->
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time-hibernate</artifactId>
|
||||
<version>${jodatime-hibernate.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time-jsptags</artifactId>
|
||||
<version>${jodatime-jsptags.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jadira.usertype</groupId>
|
||||
<artifactId>usertype.core</artifactId>
|
||||
<version>${jadira-usertype-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Databases - Uses HSQL by default -->
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
<petclinic:layout pageName="owners">
|
||||
|
@ -54,7 +53,7 @@
|
|||
<dt>Name</dt>
|
||||
<dd><c:out value="${pet.name}"/></dd>
|
||||
<dt>Birth Date</dt>
|
||||
<dd><joda:format value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd>
|
||||
<dd><fmt:formatDate value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd>
|
||||
<dt>Type</dt>
|
||||
<dd><c:out value="${pet.type.name}"/></dd>
|
||||
</dl>
|
||||
|
@ -69,7 +68,7 @@
|
|||
</thead>
|
||||
<c:forEach var="visit" items="${pet.visits}">
|
||||
<tr>
|
||||
<td><joda:format value="${visit.date}" pattern="yyyy-MM-dd"/></td>
|
||||
<td><fmt:formatDate value="${visit.date}" pattern="yyyy-MM-dd"/></td>
|
||||
<td><c:out value="${visit.description}"/></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
|
||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||
|
||||
|
||||
|
@ -30,7 +29,7 @@
|
|||
</thead>
|
||||
<tr>
|
||||
<td><c:out value="${visit.pet.name}"/></td>
|
||||
<td><joda:format value="${visit.pet.birthDate}" pattern="yyyy/MM/dd"/></td>
|
||||
<td><fmt:formatDate value="${visit.pet.birthDate}" pattern="yyyy/MM/dd"/></td>
|
||||
<td><c:out value="${visit.pet.type.name}"/></td>
|
||||
<td><c:out value="${visit.pet.owner.firstName} ${visit.pet.owner.lastName}"/></td>
|
||||
</tr>
|
||||
|
@ -60,7 +59,7 @@
|
|||
<c:forEach var="visit" items="${visit.pet.visits}">
|
||||
<c:if test="${!visit['new']}">
|
||||
<tr>
|
||||
<td><joda:format value="${visit.date}" pattern="yyyy/MM/dd"/></td>
|
||||
<td><fmt:formatDate value="${visit.date}" pattern="yyyy/MM/dd"/></td>
|
||||
<td><c:out value="${visit.description}"/></td>
|
||||
</tr>
|
||||
</c:if>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.springframework.samples.petclinic.service;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -13,6 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class ClinicServiceSpringDataJpaTests {
|
|||
pet.setName("bowser");
|
||||
Collection<PetType> types = this.clinicService.findPetTypes();
|
||||
pet.setType(EntityUtils.getById(types, PetType.class, 2));
|
||||
pet.setBirthDate(new LocalDate());
|
||||
pet.setBirthDate(new Date());
|
||||
owner6.addPet(pet);
|
||||
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
|
||||
|
||||
|
|
Loading…
Reference in a new issue