Skip to content
Snippets Groups Projects
Commit a9b6565f authored by Dapeng's avatar Dapeng Committed by Antoine Rey
Browse files

Remove dependency with joda time to simplify the project dependencies

parent 4d90e7e3
No related branches found
No related tags found
No related merge requests found
...@@ -21,11 +21,6 @@ ...@@ -21,11 +21,6 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<docker.image.prefix>arey</docker.image.prefix> <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 --> <!-- Web dependencies -->
<webjars-bootstrap.version>3.3.6</webjars-bootstrap.version> <webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
<webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version> <webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
...@@ -71,27 +66,6 @@ ...@@ -71,27 +66,6 @@
<artifactId>jstl</artifactId> <artifactId>jstl</artifactId>
</dependency> </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 --> <!-- Databases - Uses HSQL by default -->
<dependency> <dependency>
<groupId>org.hsqldb</groupId> <groupId>org.hsqldb</groupId>
......
...@@ -15,11 +15,9 @@ ...@@ -15,11 +15,9 @@
*/ */
package org.springframework.samples.petclinic.model; package org.springframework.samples.petclinic.model;
import java.util.ArrayList; import org.springframework.beans.support.MutableSortDefinition;
import java.util.Collections; import org.springframework.beans.support.PropertyComparator;
import java.util.HashSet; import org.springframework.format.annotation.DateTimeFormat;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
...@@ -30,12 +28,14 @@ import javax.persistence.ManyToOne; ...@@ -30,12 +28,14 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.annotations.Type; import javax.persistence.Temporal;
import org.joda.time.DateTime; import javax.persistence.TemporalType;
import org.joda.time.LocalDate; import java.util.ArrayList;
import org.springframework.beans.support.MutableSortDefinition; import java.util.Collections;
import org.springframework.beans.support.PropertyComparator; import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat; import java.util.HashSet;
import java.util.List;
import java.util.Set;
/** /**
* Simple business object representing a pet. * Simple business object representing a pet.
...@@ -49,9 +49,9 @@ import org.springframework.format.annotation.DateTimeFormat; ...@@ -49,9 +49,9 @@ import org.springframework.format.annotation.DateTimeFormat;
public class Pet extends NamedEntity { public class Pet extends NamedEntity {
@Column(name = "birth_date") @Column(name = "birth_date")
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate") @Temporal(TemporalType.DATE)
@DateTimeFormat(pattern = "yyyy/MM/dd") @DateTimeFormat(pattern = "yyyy/MM/dd")
private LocalDate birthDate; private Date birthDate;
@ManyToOne @ManyToOne
@JoinColumn(name = "type_id") @JoinColumn(name = "type_id")
...@@ -64,14 +64,15 @@ public class Pet extends NamedEntity { ...@@ -64,14 +64,15 @@ public class Pet extends NamedEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
private Set<Visit> visits; private Set<Visit> visits;
public LocalDate getBirthDate() {
return this.birthDate;
}
public void setBirthDate(LocalDate birthDate) { public void setBirthDate(Date birthDate) {
this.birthDate = birthDate; this.birthDate = birthDate;
} }
public Date getBirthDate() {
return this.birthDate;
}
public PetType getType() { public PetType getType() {
return this.type; return this.type;
} }
......
...@@ -15,16 +15,17 @@ ...@@ -15,16 +15,17 @@
*/ */
package org.springframework.samples.petclinic.model; 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.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import org.hibernate.annotations.Type; import javax.persistence.TemporalType;
import org.hibernate.validator.constraints.NotEmpty; import java.util.Date;
import org.joda.time.LocalDate;
import org.springframework.format.annotation.DateTimeFormat;
/** /**
* Simple JavaBean domain object representing a visit. * Simple JavaBean domain object representing a visit.
...@@ -39,9 +40,9 @@ public class Visit extends BaseEntity { ...@@ -39,9 +40,9 @@ public class Visit extends BaseEntity {
* Holds value of property date. * Holds value of property date.
*/ */
@Column(name = "visit_date") @Column(name = "visit_date")
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate") @Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(pattern = "yyyy/MM/dd") @DateTimeFormat(pattern = "yyyy/MM/dd")
private LocalDate date; private Date date;
/** /**
* Holds value of property description. * Holds value of property description.
...@@ -62,7 +63,7 @@ public class Visit extends BaseEntity { ...@@ -62,7 +63,7 @@ public class Visit extends BaseEntity {
* Creates a new instance of Visit for the current date * Creates a new instance of Visit for the current date
*/ */
public Visit() { public Visit() {
this.date = new LocalDate(); this.date = new Date();
} }
...@@ -71,7 +72,7 @@ public class Visit extends BaseEntity { ...@@ -71,7 +72,7 @@ public class Visit extends BaseEntity {
* *
* @return Value of property date. * @return Value of property date.
*/ */
public LocalDate getDate() { public Date getDate() {
return this.date; return this.date;
} }
...@@ -80,7 +81,7 @@ public class Visit extends BaseEntity { ...@@ -80,7 +81,7 @@ public class Visit extends BaseEntity {
* *
* @param date New value of property date. * @param date New value of property date.
*/ */
public void setDate(LocalDate date) { public void setDate(Date date) {
this.date = date; this.date = date;
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ 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" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
<petclinic:layout pageName="owners"> <petclinic:layout pageName="owners">
...@@ -54,7 +53,7 @@ ...@@ -54,7 +53,7 @@
<dt>Name</dt> <dt>Name</dt>
<dd><c:out value="${pet.name}"/></dd> <dd><c:out value="${pet.name}"/></dd>
<dt>Birth Date</dt> <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> <dt>Type</dt>
<dd><c:out value="${pet.type.name}"/></dd> <dd><c:out value="${pet.type.name}"/></dd>
</dl> </dl>
...@@ -69,7 +68,7 @@ ...@@ -69,7 +68,7 @@
</thead> </thead>
<c:forEach var="visit" items="${pet.visits}"> <c:forEach var="visit" items="${pet.visits}">
<tr> <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> <td><c:out value="${visit.description}"/></td>
</tr> </tr>
</c:forEach> </c:forEach>
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ 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" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
...@@ -30,7 +29,7 @@ ...@@ -30,7 +29,7 @@
</thead> </thead>
<tr> <tr>
<td><c:out value="${visit.pet.name}"/></td> <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.type.name}"/></td>
<td><c:out value="${visit.pet.owner.firstName} ${visit.pet.owner.lastName}"/></td> <td><c:out value="${visit.pet.owner.firstName} ${visit.pet.owner.lastName}"/></td>
</tr> </tr>
...@@ -60,7 +59,7 @@ ...@@ -60,7 +59,7 @@
<c:forEach var="visit" items="${visit.pet.visits}"> <c:forEach var="visit" items="${visit.pet.visits}">
<c:if test="${!visit['new']}"> <c:if test="${!visit['new']}">
<tr> <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> <td><c:out value="${visit.description}"/></td>
</tr> </tr>
</c:if> </c:if>
......
package org.springframework.samples.petclinic.service; package org.springframework.samples.petclinic.service;
import org.joda.time.LocalDate;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,6 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; ...@@ -13,6 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -123,7 +123,7 @@ public class ClinicServiceSpringDataJpaTests { ...@@ -123,7 +123,7 @@ public class ClinicServiceSpringDataJpaTests {
pet.setName("bowser"); pet.setName("bowser");
Collection<PetType> types = this.clinicService.findPetTypes(); Collection<PetType> types = this.clinicService.findPetTypes();
pet.setType(EntityUtils.getById(types, PetType.class, 2)); pet.setType(EntityUtils.getById(types, PetType.class, 2));
pet.setBirthDate(new LocalDate()); pet.setBirthDate(new Date());
owner6.addPet(pet); owner6.addPet(pet);
assertThat(owner6.getPets().size()).isEqualTo(found + 1); assertThat(owner6.getPets().size()).isEqualTo(found + 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment