Skip to content
Snippets Groups Projects
Commit 288548c6 authored by Antoine Rey's avatar Antoine Rey
Browse files

Merge pull request #113 from trepel/visitdatefix

Using jodatime LocalDate instead of DateTime for visits
parents 19d77673 e00dfb3f
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ import javax.persistence.Table; ...@@ -23,7 +23,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import org.joda.time.DateTime; import org.joda.time.LocalDate;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
/** /**
...@@ -39,9 +39,9 @@ public class Visit extends BaseEntity { ...@@ -39,9 +39,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.PersistentDateTime") @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
@DateTimeFormat(pattern = "yyyy/MM/dd") @DateTimeFormat(pattern = "yyyy/MM/dd")
private DateTime date; private LocalDate date;
/** /**
* Holds value of property description. * Holds value of property description.
...@@ -62,7 +62,7 @@ public class Visit extends BaseEntity { ...@@ -62,7 +62,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 DateTime(); this.date = new LocalDate();
} }
...@@ -71,7 +71,7 @@ public class Visit extends BaseEntity { ...@@ -71,7 +71,7 @@ public class Visit extends BaseEntity {
* *
* @return Value of property date. * @return Value of property date.
*/ */
public DateTime getDate() { public LocalDate getDate() {
return this.date; return this.date;
} }
...@@ -80,7 +80,7 @@ public class Visit extends BaseEntity { ...@@ -80,7 +80,7 @@ public class Visit extends BaseEntity {
* *
* @param date New value of property date. * @param date New value of property date.
*/ */
public void setDate(DateTime date) { public void setDate(LocalDate date) {
this.date = date; this.date = date;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
package org.springframework.samples.petclinic.repository.jdbc; package org.springframework.samples.petclinic.repository.jdbc;
import org.joda.time.DateTime; import org.joda.time.LocalDate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.samples.petclinic.model.Visit; import org.springframework.samples.petclinic.model.Visit;
...@@ -35,7 +35,7 @@ class JdbcVisitRowMapper implements RowMapper<Visit> { ...@@ -35,7 +35,7 @@ class JdbcVisitRowMapper implements RowMapper<Visit> {
Visit visit = new Visit(); Visit visit = new Visit();
visit.setId(rs.getInt("visit_id")); visit.setId(rs.getInt("visit_id"));
Date visitDate = rs.getDate("visit_date"); Date visitDate = rs.getDate("visit_date");
visit.setDate(new DateTime(visitDate)); visit.setDate(new LocalDate(visitDate));
visit.setDescription(rs.getString("description")); visit.setDescription(rs.getString("description"));
return visit; return visit;
} }
......
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