2

I got a <p:calendar> and want to use today's date as placeholder.

My attempt is to use OmniFaces #{now} in combination with a:placeholder for this:

<p:calendar id="calendar" a:placeholder="#{now}" minHour="8" locale="de" 
maxHour="20" value="#{adminSeminarAlleBearbeitung.seminar.someproperty}" 
pattern="dd.MM.yyyy HH:mm" />

Where someproperty is a java.util.date. This is working so far, but I want to format the date like dd.MM.yyyy HH:mm.

How can I achieve this?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
alexander
  • 1,191
  • 2
  • 20
  • 40

1 Answers1

3

Use of:formatDate() function in EL:

<p:calendar ... a:placeholder="#{of:formatDate(now, 'dd.MM.yyyy HH:mm')}" />

Or if you'd like to reuse calendar component's own pattern attribute:

<p:calendar ... a:placeholder="#{of:formatDate(now, component.pattern)}" pattern="dd.MM.yyyy HH:mm" />

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555