Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: Spring 3.0 annotated formatting: style/pattern not applied

  1. #21

    Default

    Maybe everybody knew it already, so this message is for myself only: Joda time is needed if @DateTimeFormat is used or we'll see sth like:
    Code:
    20:15:10 DEBUG AbstractHandlerExceptionResolver:132 - Resolving exception from handler [home.OneController@1f5cbd6]: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "30-041982" from type 'java.lang.String' to type 'java.util.Date'; nested exception is java.lang.IllegalStateException: JodaTime library not available - @DateTimeFormat not supported
    20:15:10 DEBUG AbstractHandlerExceptionResolver:132 - Resolving exception from handler [home.OneController@1f5cbd6]: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "30-041982" from type 'java.lang.String' to type 'java.util.Date'; nested exception is java.lang.IllegalStateException: JodaTime library not available - @DateTimeFormat not supported
    20:15:10 DEBUG AbstractHandlerExceptionResolver:132 - Resolving exception from handler [home.OneController@1f5cbd6]: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "30-041982" from type 'java.lang.String' to type 'java.util.Date'; nested exception is java.lang.IllegalStateException: JodaTime library not available - @DateTimeFormat not supported
    20:15:10 DEBUG DispatcherServlet:824 - Null ModelAndView returned to DispatcherServlet with name 'test': assuming HandlerAdapter completed request handling
    20:15:10 DEBUG FrameworkServlet:699 - Successfully completed request
    The spring-mvc-showcase on github also says that.

  2. #22
    Join Date
    Dec 2011
    Posts
    11

    Default

    I've read that @DateTimeFormat is avaiable in Spring MVC, but I'm working with Spring Portlets. Is it avaiable for this case too? How I have to proceed? must I include <mvc:annotation-driven/> in my applicattion-context.xml file too?

    Now I'm printting my @DateTimeFormat date in a JSP without obtaining the expected result:


    @DateTimeFormat(pattern="dd-MM-yyyy")
    private java.util.Date myDate;

    and that's what I have printed: 2011-12-30 10:06:18.0 as result of <c:out value="${myForm.myDate}"></c:out>

    I've tried also with @DateTimeFormat(style="S-"), including and excluding the <mvc:annotation-driven/> and obtaining the same result, some help?

  3. #23

    Default

    In Spring 3.1 @NumberFormatter does not allow pattern to be used for Currency or Percent types so the fractionDigits is a needed and missing annotation field. Furthermore rounding is always ROUND_HALF_EVEN (the default for BigDecimal) meaning rounding is a needed and missing annotation field. Another useful missing property is multiplier. That is the reason I had to come up with a CustomNumberFormatter and bunch of classes that I have documented at http://thinkinginsoftware.blogspot.c...on-driven.html, hopefully it will be useful as a tutorial to get custom Converters working in Spring.
    Best,
    -Nestor

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •