Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7883347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:30:26+00:00 2026-06-03T04:30:26+00:00

I have a tag with the following: <%@ tag body-content=empty%> <%@ attribute name=timestamp required=true

  • 0

I have a tag with the following:

<%@ tag body-content="empty"%>
<%@ attribute name="timestamp" required="true" type="java.sql.Timestamp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:useBean id="dateValue" class="java.util.Date" />
<c:if test="${not empty timestamp}">
    <jsp:setProperty name="dateValue" property="time" value="${timestamp}" />
    <span title="${timestamp}"> <fmt:formatDate value="${dateValue}"
            pattern="MM/dd/yyyy HH:mm" /> </span>
</c:if>

I get the following error however:

Error 500: com.ibm.ws.jsp.JspCoreException: java.lang.IllegalArgumentException: Cannot convert 5/1/12 10:36 AM of type class java.sql.Timestamp to long

I was trying to follow this answer to convert a timestamp to a date in JSTL, so I wouldn’t have change anything in my servlet. How can I convert a java.sql.Timestamp to a date so that formatDate can work with it, using JSTL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:30:28+00:00Added an answer on June 3, 2026 at 4:30 am

    You need to pass in Timestamp#getTime().

    <jsp:setProperty name="dateValue" property="time" value="${timestamp.time}" />
    

    But this makes all no sense. The java.sql.Timestamp is already a subclass of java.util.Date. So this should also do:

    <%@ attribute name="timestamp" required="true" type="java.sql.Timestamp"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
    <c:if test="${not empty timestamp}">
        <span title="${timestamp}"><fmt:formatDate value="${timestamp}"
                pattern="MM/dd/yyyy HH:mm" /></span>
    </c:if>
    

    I’d by the way also change your models to declare the property as java.util.Date instead. You should not use java.sql.Timestamp in the model and view, but only in the data layer. You don’t need to convert ResultSet#getTimestamp() to java.util.Date by parsing/formatting. Just upcasting is sufficient.

    E.g.

    import java.util.Date;
    
    public class SomeModel {
    
        private Date somefield;
    
        // ...
    }
    

    with

    someModel.setSomefield(resultSet.getTimestamp("somefield"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSS with the following attribute to the body tag and header:
For example, I have the following tag which its content is short <div>It is
I have the following code: Tag.find_all_by_company_id(4).each.collect{|tag| tag.name }.join(,) (Essentially I'm trying to build a
I have the following SQL: SELECT * FROM [Database].dbo.[TagsPerItem] INNER JOIN [Database].dbo.[Tag] ON [Tag].Id
I have the following tag with a Html.TextBoxFor expression and I want the contents
In my xhtml page I have the following tag included: <f:view locale=#{languageBean.locale}> ... </f:view>
I have the following div tag within my html file: <div id='attendeelist'></div> I am
I have the following Application tag code in my widget: <mx:Application xmlns:mx=http://www.adobe.com/2006/mxml xmlns:local=* width=100%
I have the following method which serialises an object to a HTML tag. I
I have a following situation in my project. There are some tag values which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.