tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stuart Thiel <stuart.th...@gmail.com>
Subject Re: How to convert String to Date in EL?
Date Mon, 19 Aug 2019 04:01:01 GMT
Hello Kazuaki,

A quick google is probably more effective than mailing this list every time:
https://stackoverflow.com/questions/6162401/convert-and-format-a-date-in-jsp

The solution with fmt:parseDate is likely what you want, but read what
they say and perhaps change what you're doing a bit.

On Sun, Aug 18, 2019 at 11:46 PM Kazuaki Miyauchi <miyauchk@gmail.com> wrote:
>
>  I made following JSP.
>
> <%@ page contentType="text/html;charset=UTF-8"%>
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
>
> <html>
> <head>
>   <title>Insert Date</title>
> </head>
> <body>
>
> <c:catch var="ex">
> <sql:setDataSource dataSource="jdbc/kome" var="kome"/>
> <sql:update var="stmt" dataSource="${kome}">
>  insert into test values(?,?)
>  <sql:dateParam value="2019-8-19" type="DATE"/>
>  <sql:param value="Good Day"/>
> </sql:update>
> </c:catch>
>
> <c:if test="${not empty ex}">
>  <c:out value="${ex}" />
> </c:if>
> </body>
> </html>
>
> Table was simply made as following.
> create table test (when_cause date, how text);
>
>  Then, I got following error in tomcat-9.0.22.
> org.apache.jasper.JasperException: Unable to convert string
> [2019-8-19] to class [java.util.Date] for attribute [value]: [Property
> Editor not registered with the PropertyEditorManager]
>
>  How to convert String date data to Date type?
>
>  After changing as following, it works.
> But, it's not easily readable when making complicated sql.
>
> <sql:update var="stmt" dataSource="${kome}">
>  insert into test values('2019-8-19',?)
>  <sql:param value="Good Day"/>
> </sql:update>
>
> Regards,                         Kazuaki Miyauchi, Japan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: taglibs-user-help@tomcat.apache.org
>


-- 
Stuart Thiel, P. Eng.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@tomcat.apache.org
For additional commands, e-mail: taglibs-user-help@tomcat.apache.org


Mime
View raw message