SnIpEr ReLoAdEd
SnIpEr ReLoAdEd

Reputation: 72

Getting same birthday for all users in Liferay

I am trying to display age in years on my jsp. I converted the birthday to years.

But I am getting same age for all the users.

Before converting to years also, the birthday was still the same for all the users i.e (Tue Aug 02 11:44:26 GMT 2022) in jsp but different in the DB.

After converting i am getting the age as 52 for all the users (I think its taking default age of liferay 1970-01-01 00:00:00).

Can anyone please tell how to get the same birthday as stored in DB.

This is how i tried.

<td>    
    <fmt:parseDate type = "date" pattern = "yyyy-MM-dd" var = "parsedDate" value = "${listContacts.birthday}"/>
    <jsp:useBean id = "today" class = "java.util.Date" />  
    <fmt:parseNumber type = "number" integerOnly = "true" value = "${(today.time - parsedDate.time)/(1000 * 60 * 60 * 24 * 365)}"/>                  
</td>

Edit 1

This is how i am retrieving the list of users:

List<User> getUsers = UserLocalServiceUtil.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
renderRequest.setAttribute("users", getUsers);

For retrieving the birthday from contact_ table:

List<Contact> getContacts = ContactLocalServiceUtil.getContacts(-1, 1);
renderRequest.setAttribute("contacts", getContacts);

Edit 2

I tried to do these two ways also, But getting the same exceptions for both of them.

First:

<td>
    <c:forEach var = "listContacts" items = "${contacts}">      
        <fmt:parseDate type = "date" pattern = "yyyy-MM-dd" var = "parsedDate" value = "${listContacts.birthday}"/>
        <jsp:useBean id = "today" class = "java.util.Date" />  
        <fmt:parseNumber type = "number" integerOnly = "true" value = "${(today.time - parsedDate.time)/(1000 * 60 * 60 * 24 * 365)}"/>                  
    </c:forEach>
</td>

Second: So that i can compare the id's in both the table and display them.

<td>
    <c:forEach var = "listContacts" items = "${contacts}">  
        <c:if test = "${listUsers.userId eq listContacts.userId}">      
            <fmt:parseDate type = "date" pattern = "yyyy-MM-dd" var = "parsedDate" value = "${listContacts.birthday}"/>
            <jsp:useBean id = "today" class = "java.util.Date" />  
            <fmt:parseNumber type = "number" integerOnly = "true" value = "${(today.time - parsedDate.time)/(1000 * 60 * 60 * 24 * 365)}"/>                  
        </c:if> 
    </c:forEach>
</td>

Stack Trace:

2022-08-03 10:06:20.914 ERROR [http-nio-8080-exec-3][PortletRequestDispatcherImpl:331] Unable to dispatch request: In &lt;parseDate&gt;, value attribute can not be parsed: "Tue Aug 02 11:44:26 GMT 2022"
2022-08-03 10:06:20.916 ERROR [http-nio-8080-exec-3][PortletServlet:112] javax.portlet.PortletException: javax.servlet.ServletException: In &lt;parseDate&gt;, value attribute can not be parsed: "Tue Aug 02 11:44:26 GMT 2022"
javax.portlet.PortletException: javax.servlet.ServletException: In &lt;parseDate&gt;, value attribute can not be parsed: "Tue Aug 02 11:44:26 GMT 2022"
    at com.liferay.portlet.internal.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:333)
    at com.liferay.portlet.internal.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:128)
    at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.include(MVCPortlet.java:589)
    at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.include(MVCPortlet.java:605)
    at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:489)
    at javax.portlet.GenericPortlet.render(GenericPortlet.java:291)
    at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.render(MVCPortlet.java:316)
    at my.registration.form.portlet.MyRegistrationFormPortlet.render(MyRegistrationFormPortlet.java:96)
    at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:127)
    at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:58)
    at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:124)
    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:108)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
    at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62)
    at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)
    at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)
    at com.liferay.portlet.internal.InvokerPortletImpl.invoke(InvokerPortletImpl.java:564)
    at com.liferay.portlet.internal.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:660)
    at com.liferay.portlet.internal.InvokerPortletImpl.render(InvokerPortletImpl.java:357)
    at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.lambda$render$0(MonitoringInvokerPortlet.java:280)
    at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet._render(MonitoringInvokerPortlet.java:383)
    at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.render(MonitoringInvokerPortlet.java:278)
    at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1534)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:64)
    at com.liferay.portal.servlet.DirectRequestDispatcherFactoryImpl$IndirectRequestDispatcher.include(DirectRequestDispatcherFactoryImpl.java:202)
    at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:79)
    at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
    at com.liferay.portal.servlet.TransferHeadersHelperImpl$TransferHeadersRequestDispatcher.include(TransferHeadersHelperImpl.java:162)
    at com.liferay.portlet.internal.PortletContainerImpl._render(PortletContainerImpl.java:870)
    at com.liferay.portlet.internal.PortletContainerImpl.lambda$render$2(PortletContainerImpl.java:216)
    at com.liferay.portlet.internal.PortletContainerImpl._preserveGroupIds(PortletContainerImpl.java:395)
    at com.liferay.portlet.internal.PortletContainerImpl.render(PortletContainerImpl.java:205)
    at com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:142)
    at com.liferay.portlet.RestrictPortletContainerWrapper.lambda$render$0(RestrictPortletContainerWrapper.java:126)
    at com.liferay.portlet.RestrictPortletContainerWrapper._render(RestrictPortletContainerWrapper.java:183)
    at com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:124)
    at com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:212)
    at com.liferay.portal.layoutconfiguration.util.PortletRenderer._render(PortletRenderer.java:192)
    at com.liferay.portal.layoutconfiguration.util.PortletRenderer.render(PortletRenderer.java:84)
    at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doProcessTemplate(RuntimePageImpl.java:568)
    at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doDispatch(RuntimePageImpl.java:340)
    at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:154)
    at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:175)
    at com.liferay.portal.kernel.layoutconfiguration.util.RuntimePageUtil.processTemplate(RuntimePageUtil.java:94)
    at org.apache.jsp.html.portal.layout.view.portlet_jsp._jspService(portlet_jsp.java:728)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:64)
    at com.liferay.portal.servlet.DirectRequestDispatcherFactoryImpl$IndirectRequestDispatcher.include(DirectRequestDispatcherFactoryImpl.java:202)
    at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:79)
    at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
    at com.liferay.portal.servlet.TransferHeadersHelperImpl$TransferHeadersRequestDispatcher.include(TransferHeadersHelperImpl.java:162)
    at com.liferay.portal.model.impl.LayoutTypeControllerImpl.includeLayoutContent(LayoutTypeControllerImpl.java:171)
    at com.liferay.portal.model.impl.LayoutImpl.includeLayoutContent(LayoutImpl.java:904)
    at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:407)
    at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:174)
    at com.liferay.portal.struts.PortalRequestProcessor._processActionPerform(PortalRequestProcessor.java:706)
    at com.liferay.portal.struts.PortalRequestProcessor._process(PortalRequestProcessor.java:646)
    at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:194)
    at com.liferay.portal.servlet.MainServlet.process(MainServlet.java:1067)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:598)
    at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:575)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:103)
    at com.liferay.portal.apio.internal.architect.servlet.filter.APIDocumentationFilter.processFilter(APIDocumentationFilter.java:74)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:57)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:340)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:178)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at com.liferay.friendly.url.internal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:372)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at com.liferay.portal.servlet.ServletAdapter.service(ServletAdapter.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:103)
    at com.liferay.portal.apio.internal.architect.servlet.filter.APIDocumentationFilter.processFilter(APIDocumentationFilter.java:74)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:340)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:360)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:57)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:340)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:260)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:263)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
    at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:178)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
    at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
    at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
    at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.servlet.ServletException: In &lt;parseDate&gt;, value attribute can not be parsed: "Tue Aug 02 11:44:26 GMT 2022"
    at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:950)
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:885)
    at com.liferay.taglib.servlet.PageContextWrapper.handlePageException(PageContextWrapper.java:173)
    at org.apache.jsp.listUser_jsp._jspService(listUser_jsp:379)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at com.liferay.portal.osgi.web.servlet.jsp.compiler.internal.JspServlet.service(JspServlet.java:319)
    at com.liferay.portal.osgi.web.servlet.jsp.compiler.internal.JspServlet.service(JspServlet.java:330)
    at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
    at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62)
    at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)
    at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)
    at com.liferay.portlet.internal.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:318)
    ... 193 more
Caused by: java.text.ParseException: Unparseable date: "Tue Aug 02 11:44:26 GMT 2022"
    at java.text.DateFormat.parse(DateFormat.java:366)
    at org.apache.taglibs.standard.tag.common.fmt.ParseDateSupport.doEndTag(ParseDateSupport.java:219)
    at org.apache.jsp.listUser_jsp._jspx_meth_fmt_parseDate_0(listUser_jsp:642)
    at org.apache.jsp.listUser_jsp._jspx_meth_c_forEach_1(listUser_jsp:592)
    at org.apache.jsp.listUser_jsp._jspService(listUser_jsp:343)
    ... 206 more
2022-08-03 10:06:20.922 ERROR [http-nio-8080-exec-3][render_portlet_jsp:131] null
java.text.ParseException: Unparseable date: "Tue Aug 02 11:44:26 GMT 2022"
    at java.text.DateFormat.parse(DateFormat.java:366)
    at org.apache.taglibs.standard.tag.common.fmt.ParseDateSupport.doEndTag(ParseDateSupport.java:219)
    at org.apache.jsp.listUser_jsp._jspx_meth_fmt_parseDate_0(listUser_jsp:642)
    at org.apache.jsp.listUser_jsp._jspx_meth_c_forEach_1(listUser_jsp:592)
    at org.apache.jsp.listUser_jsp._jspService(listUser_jsp:343)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at com.liferay.portal.osgi.web.servlet.jsp.compiler.internal.JspServlet.service(JspServlet.java:319)
    at com.liferay.portal.osgi.web.servlet.jsp.compiler.internal.JspServlet.service(JspServlet.java:330)
    at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
    at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62)
    at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)
    at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)
    at com.liferay.portlet.internal.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:318)
    at com.liferay.portlet.internal.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:128)
    at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.include(MVCPortlet.java:589)

Upvotes: 0

Views: 134

Answers (2)

SnIpEr ReLoAdEd
SnIpEr ReLoAdEd

Reputation: 72

Earlier I was only getting the data for one user. I changed it to.

//  for retrieving all Contact Details from "contact_" table form db
            
List<Contact> getContacts = ContactLocalServiceUtil.getContacts(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
renderRequest.setAttribute("contacts", getContacts);

Then changed my code in JSP like this.

<td>
    <c:forEach var = "listContacts" items = "${contacts}">  // For retrieving the contact list from DB.
        <c:if test = "${listContacts.userId eq listUsers.userId}">  // For Equating the ID's in contact_ table and user_ table. 
            <fmt:formatDate type = "date" pattern = "yyyy-MM-dd" var = "parsedDate" value = "${listContacts.birthday}"/>
            <jsp:useBean id = "today" class = "java.util.Date" />  
            <fmt:parseNumber type = "number" integerOnly = "true" value = "${(today.time - listContacts.birthday.time)/(1000 * 60 * 60 * 24 * 365)}"/>  // Taking the difference between todays time and dob and converting it in years.             
        </c:if>  
    </c:forEach>
</td> 

Upvotes: 0

Olaf Kock
Olaf Kock

Reputation: 48057

Some suggestions - let me know if one of them works:

  1. figure out if User or Contact hold the birthday. In your code, you're using ${listContacts.birthday} - and if they're not in the contacts, but in the users - here's a problem.
  2. It looks like you're parsing "Tue Aug 02 11:44:26 GMT 2022" with the pattern "yyyy-MM-dd" - there's quite some mismatch between the two (but I'm not your regular JSTL guy - take this one with a grain of salt.
  3. before you do any math on the date: output ${parsedDate} directly on the page, to see what you got, and if it matches with your expectation from the currently shown user's birthdate.

Upvotes: 2

Related Questions