Skip to content

Commit

Permalink
Fix formatting of dates in Qute templates (#8)
Browse files Browse the repository at this point in the history
Fixes: #7
  • Loading branch information
geoand authored Jan 24, 2023
1 parent 3bc208a commit 90ccf55
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
22 changes: 22 additions & 0 deletions src/main/java/org/quarkus/samples/petclinic/Temporals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.quarkus.samples.petclinic;

import io.quarkus.qute.TemplateExtension;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
* This is a temporary hack around
* <a href="https://github.com/redhat-developer-demos/quarkus-petclinic/issues/7">this</a> issue.
* <p>
* The problem appears to be M1 specific and is being
* <a href="https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/petclinic">looked</a> into by the Quarkus devs.
*/
@TemplateExtension
public class Temporals {

private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

public static String format(LocalDate localDate) {
return localDate.format(FORMATTER);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/templates/createOrUpdateVisitForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>
</thead>
<tr>
<td>{pet.name}</td>
<td>{pet.birthDate.format('yyyy-MM-dd')}</td>
<td>{pet.birthDate.format()}</td>
<td>{pet.type.name}</td>
<td>{pet.owner.firstName} {pet.owner.lastName}</td>
</tr>
Expand Down Expand Up @@ -74,7 +74,7 @@ <h2>
<tr>
{#if visit}
{#for v in pet.visits}
<td>{v.date.format('yyyy-MM-dd')}</td>
<td>{v.date.format()}</td>
<td>{v.description}</td>
{/for}
{/if}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/ownerDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2>{msg:pets_and_visits}</h2>
<dt>{msg:name}</dt>
<dd>{pet.name}</dd>
<dt>{msg:birthdate}</dt>
<dd>{pet.birthDate.format('yyyy-MM-dd')}</dd>
<dd>{pet.birthDate.format()}</dd>
<dt>{msg:type}</dt>
<dd>{pet.type.stringify}</dd>
</dl>
Expand All @@ -62,7 +62,7 @@ <h2>{msg:pets_and_visits}</h2>
</thead>
{#for visit in pet.visits}
<tr>
<td>{visit.date.format('yyyy-MM-dd')}</td>
<td>{visit.date.format()}</td>
<td>{visit.description ?: ''}</td>
</tr>
{/for}
Expand Down

0 comments on commit 90ccf55

Please sign in to comment.