From 07e535a75e90bacd1f62851b371821b4df084dc8 Mon Sep 17 00:00:00 2001 From: Mic <misvy@vmware.com> Date: Wed, 6 Feb 2013 17:41:38 +0800 Subject: [PATCH] fixed issue in the 'createVisit' form --- .../springframework/samples/petclinic/Visit.java | 2 ++ .../WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/Visit.java b/src/main/java/org/springframework/samples/petclinic/Visit.java index a5a788f..30b38b4 100644 --- a/src/main/java/org/springframework/samples/petclinic/Visit.java +++ b/src/main/java/org/springframework/samples/petclinic/Visit.java @@ -10,6 +10,7 @@ import javax.validation.constraints.Size; import org.hibernate.annotations.Type; import org.joda.time.DateTime; +import org.springframework.format.annotation.DateTimeFormat; /** * Simple JavaBean domain object representing a visit. @@ -22,6 +23,7 @@ public class Visit extends BaseEntity { /** Holds value of property date. */ @Column(name="visit_date") @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") + @DateTimeFormat(pattern="yyyy/MM/dd") private DateTime date; /** Holds value of property description. */ diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp index c3f8b9c..f073b55 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp @@ -8,13 +8,19 @@ <jsp:include page="../fragments/headTag.jsp"/> + <body> + <script> + $(function() { + $("#date").datepicker({ dateFormat: 'yy/mm/dd'}); + }); + </script> <div class="container"> <jsp:include page="../fragments/bodyHeader.jsp"/> <h2><c:if test="${visit['new']}">New </c:if>Visit:</h2> <form:form modelAttribute="visit"> - <b>Pet:</b> + <b>Pet</b> <table class="table table-striped"> <thead> <tr> @@ -26,7 +32,7 @@ </thead> <tr> <td><c:out value="${visit.pet.name}" /></td> - <td><joda:format value="${visit.pet.birthDate}" pattern="yyyy-MM-dd"/></td> + <td><joda:format 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> @@ -39,7 +45,7 @@ <br/><form:errors path="date" cssClass="errors"/> </th> <td> - <form:input path="date" size="10" maxlength="10"/> (yyyy-mm-dd) + <form:input path="date" size="10" maxlength="10"/> </td> <tr/> <tr> @@ -70,7 +76,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><joda:format value="${visit.date}" pattern="yyyy/MM/dd"/></td> <td><c:out value="${visit.description}" /></td> </tr> </c:if> -- GitLab