aspose file tools*
The moose likes Spring and the fly likes date format problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "date format problem" Watch "date format problem" New topic
Author

date format problem

jas preet
Ranch Hand

Joined: Mar 31, 2010
Posts: 76

I have a date that is coming from a model map in a DateTime format and displays as 2010-08-24T01:00:00.000+05:30

I want to dsiplay date in a different format such as 24 August, 2010 .. Is this possible?


Thanks Jaspreet ----- Nothing is permanent
Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
Sure, you could use the JSTL formatting tag library to format as you like. For example...
jas preet
Ranch Hand

Joined: Mar 31, 2010
Posts: 76

Thanks Mark for the reply and this is what i did,
This startDateAndTime is a joda time type format.








And this is what i get

javax.el.ELException: Cannot convert 2010-08-24T00:00:00.000+05:30 of type class org.joda.time.DateTime to class java.util.Date
org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:434)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:188)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)
org.apache.jsp.WEB_002dINF.jsp.booking.bookingInformation_jsp._jspx_meth_fmt_005fformatDate_005f0(bookingInformation_jsp.java:290)
org.apache.jsp.WEB_002dINF.jsp.booking.bookingInformation_jsp._jspx_meth_form_005fform_005f0(bookingInformation_jsp.java:149)
org.apache.jsp.WEB_002dINF.jsp.booking.bookingInformation_jsp._jspService(bookingInformation_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:650)
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:644)
org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
org.apache.tiles.renderer.impl.UntypedAttributeRenderer.write(UntypedAttributeRenderer.java:61)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:669)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:337)
org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:234)
org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:211)
org.apache.tiles.jsp.taglib.RenderTag.doEndTag(RenderTag.java:220)
org.apache.jsp.WEB_002dINF.jsp.templates.mainLayout_jsp._jspx_meth_tiles_005finsertAttribute_005f2(mainLayout_jsp.java:196)
org.apache.jsp.WEB_002dINF.jsp.templates.mainLayout_jsp._jspService(mainLayout_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:669)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:689)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:643)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:626)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:322)
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:100)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.oosmee.common.filter.SessionExpiredFilter.doFilter(SessionExpiredFilter.java:143)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
Sorry, was thinking of a java.util.Date, which is what the formatDate tag works with. This will be a little more challenging. One approach I've used for one way formatting (i.e. command to JSP only) is to have a getStringDatetime() method that does the formatting on in the command class. If you need to also bind an entered value back to your DateTime, you'll need to use a property editor.
jas preet
Ranch Hand

Joined: Mar 31, 2010
Posts: 76

Hi Mark,

i got a simpler way of doing it. a simple google search got me to joda time api for JSP. It provides date time formatting tags for joda time. Anyways thanks for that reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: date format problem