Results 1 to 2 of 2

Thread: Date format (initBinder) not converting month.

  1. #1
    Join Date
    Feb 2008
    Posts
    4

    Default Date format (initBinder) not converting month.

    Hi All,

    I am using spring mvc with hibernate 3 and orcale 10gR2 for a web based application. In one of my beans I have a date field defined as java.util.date which i format to yyyy/mm/dd using the SimpleDateFormat in the controllers initBinder method.
    Code:
    protected void initBinder(HttpServletRequest request,
                ServletRequestDataBinder binder) throws Exception
          {
             String dateFormat = getMessageSourceAccessor().getMessage("format.date",
                   "yyyy/MM/DD");
             SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/DD");
             //df.setLenient(true);
             binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(
                   df, true));
          }
    The problem is I always get the date back with the month being 01. Even if I input 2008/11/12, I get 2008/01/12.
    I am a little confused of what is going on.
    Any input is welcome.
    Thank you in advance.

  2. #2
    Join Date
    Feb 2008
    Posts
    4

    Default

    anybody with a suggestion?

Posting Permissions

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