Skip to content

Commit

Permalink
Fix formatting of dates in Qute templates
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jan 24, 2023
1 parent 3bc208a commit 9ca4037
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
15 changes: 15 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,15 @@
package org.quarkus.samples.petclinic;

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

@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 9ca4037

Please sign in to comment.