Search code examples
primefacestimezoneclock

Primefaces Clock component is not working as per the timezone attribute value


I have been using primefaces 6.2.RC2 and in one of my pages I need to show a clock with seconds ticking every second for the set timezone. For this I have been trying to use p:clock as shown below. The problem I am seeing is that when my timezone is set to EST, it still shows CST time. Looks like the timezone attribute is not working with whatever values set:

<p:clock pattern="HH:mm:ss" mode="server" timeZone="#{loginBean.timezone}"/>

Even I have tried using f.convertDateTime and that is also not working for the <p:clock/>. Is there any solution to fix this issue?


Solution

  • Did you try America/New_York as the timezone? EST is UTC - 5 hours. America/New_York is EST in the winter and EDT in the summer, so right now New York is UTC - 4 hours.

    • CST = GMT-5
    • EST = GMT-5
    • EDT = GMT-4
    • America/New_York = -4 in summer and -5 in winter and switched on daylight savings.