Results 1 to 3 of 3

Thread: DateTimeFormat with pattern

  1. #1
    Join Date
    Apr 2010
    Posts
    5

    Default DateTimeFormat with pattern

    Hi Folks,

    i am working on a gui for my database, which is supposed to store archaeological data. For this reason dating is a crucial part of it. To do this, i like to use the SQL Date type and in my backing bean the java.util.calendar. Both allow datings before Christ.
    The fields now look like this:
    Code:
     
        @Past
        @Temporal(TemporalType.DATE)
        @DateTimeFormat(pattern = "M.Y G")
        private Calendar begining;
    
        @Past
        @Temporal(TemporalType.DATE)
        @DateTimeFormat(pattern = "M.Y G")
        private Calendar ending;
    As you can see, im using Pattern instead of style. This offers me the opportunity to use datings like 01.31 BC or 01.14 AD. But for some reason, if i chance the pattern into this:
    Code:
     @DateTimeFormat(pattern = "d.M.Y G") or  @DateTimeFormat(pattern = "dd.M.Y G")
    The Day is parsed wrong. If i type into my field, 01.01.31 BC and submit it to the database it changes to 05.01.31 BC. But the mistake don't happends in the Database, its the calendar object, which contains wrong data. So, somewhere between my input field and the backing-bean, something went wrong. Know i am asking you, where and why?

    And there is another quit annoying behavior of roo if you use patterns. To represent dates, roo uses in the jspx file fmt:dateformat, and therefor you'll need a pattern, which is inserted in the controller into the modelMap. By default roo uses styles, if you now switch to pattern, roo deletes the variable in the controller, but not in the jspx, so as it turned out, nothing will be shown. If you insert the variables in question, roo deletes them from time to time, again. I guess this is intended and very usefull in normall circumestances, but how i turn this off?

    Thank you for your answers in advance,
    regards
    Nils

  2. #2
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    Currently the MVC addon only parses the style attribute (which is localizable as opposed to patterns). If you need your own patterns you can easily achieve that by pushing the relevant controller ITD introduced methods and customizing the way patterns are generated. This way you have full control.

    HTH,
    Stefan
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  3. #3
    Join Date
    Apr 2010
    Posts
    5

    Default

    Yes, that helped.
    I wasn't aware that roo automatically overrides the aspect methods.
    Thanks for the help.

Posting Permissions

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