Re: How to convert String to Date in EL?

Stuart Thiel <[email protected]> Tue, 20 Aug 2019 05:55:06 -0300
Newsgroups gmane.comp.jakarta.taglibs.user
Message-ID <CAEp2D=7X0JYbFUpP0q3YtQwsW4K3iVDfYP0BoZOrrZRh1TOByQ@mail.gmail.com>
--000000000000a6cf950590889d64
Content-Type: text/plain; charset="UTF-8"

I suspect you can skip the set tag and wrap the parseDate in the sqlParam
tag as well, but I've never mucked with sql in JSPs (I'm pretty strict
about using them exclusively as Template Views)

On Tue, Aug 20, 2019, 05:44 Stuart Thiel <[email protected]> wrote:

> Because formats for dates are so ambiguous, there's no reliable way to
> interpret. The is why you'd use the parseDate tag, probably inside a set to
> get a date object that you'd then pass to your dateparam thing. Presumably
> you could write an el "function" to do that inline if you wanted to out in
> the effort to clean your JSP further, as I don't know of such thing
> existing (though I can't imagine why it shouldn't, save to discourage
> everyone putting all their application logic and validation in JSPs)
>
> On Tue, Aug 20, 2019, 05:22 Kazuaki Miyauchi <[email protected]> wrote:
>
>> 2019-08-20 16:39 GMT+09:00, Stuart Thiel <[email protected]>:
>> > That's what parseDate does, and why I pointed you at it.
>>
>>  I also want to do like int case as following.
>>
>> <c:set var="year" value="2019" scope="session"/>
>> <c:set var="month" value="8" scope="session"/>
>> <c:set var="day" value="20" scope="session"/>
>>
>> <sql:setDataSource dataSource="jdbc/kome" var="kome"/>
>> <sql:update var="stmt" dataSource="${kome}">
>>  insert into test values(?,?)
>>  <sql:dateParam value="${year}-${month}-${day}" type="date"/>
>>  <sql:param value="Good"/>
>> </sql:update>
>>
>>  But, of course, this makes
>>
>> javax.el.ELException: Cannot convert [2019-8-20] of type [class
>> java.lang.String] to [class java.util.Date]
>>
>>  So, I'd like to know how to convert Date type using EL writing.
>> Is there simple method to convert like 0 + for int case?
>>
>>  Regards,                            Kazuaki Miyauchi, Japan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>

--000000000000a6cf950590889d64--