Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DateDisplayFormat.TOSERIALIZEABLEDATE missing time components

    I am attempting to display columns that contain full timestamps in a ListGrid. However, only the American format works properly for full stamps at the moment, which is useless outside America.

    According to the documentation, DateDisplayFormat.TOSERIALIZEABLEDATE should display:

    YYYY-MM-SS HH:mm:SS

    But instead there is a bug, it's only displaying YYYY-MM-DD. I.e. it's dropping the time part.

    Other formats that include the time component, correctly display it for the exact same dataset, so I know that this isn't a data issue.

    I would add that as the YYYY-MM-DD HH:mm:SS format is an international format (as well as the international standard), we really should have this as a proper, standalone entry in the DateDisplayFormat enum, for example, adding this entry to the end of the list:

    ISO("YYYY-MM-DD HH:mm:SS");

    Unfortunately the DateUtil settings don't seem to be working either. Right now the only way to get a reasonable date display is to use TOLOCALESTRING which is absolutely aweful because it's way too long and wordy. Totally messes up the ListGrid.

    Has someone managed to work around this problem? I desperately need to sort it out.

    #2
    If there should be a time component, declare the type of the field as "datetime", not "date". See DataSourceFieldType.

    Comment


      #3
      Originally posted by Isomorphic
      If there should be a time component, declare the type of the field as "datetime", not "date". See DataSourceFieldType.
      I did. The time component displays with SOME DateDisplayFormat such as TOLOCALESTRING, but not the ISO standard TOSERIALIZEABLEDATE.

      This is from my datasource:

      DataSourceField sendAtField = new DataSourceField("send_at", FieldType.DATETIME, "Sent at");
      DataSourceField statusAtField = new DataSourceField("status_received_at", FieldType.DATETIME, "Status Received");

      And this is in the ListGrid setup part of the code:

      ListGridField sendAtField = new ListGridField("send_at", 130);
      ListGridField statusAtField = new ListGridField("status_received_at", 100);

      sendAtField.setDateFormatter(DateDisplayFormat.TOSERIALIZEABLEDATE);

      That doesn't display the time component, but when I change it to this:
      sendAtField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);

      then suddenly I see the time component.

      Comment


        #4
        Ah, sorry, you're correct - if you want something similar to the TOSERIALIZEABLEDATE format, you'll need to add your own formatter function.

        Comment


          #5
          Hmm, unforuntately I have the same problem as in this thread here:
          http://code.google.com/p/smartgwt/issues/detail?id=227

          No matter how I try to add a customer formatter, it never changes the way that the dates come out. I tried setting the short, the normal... no changes.

          Any ideas?

          Comment


            #6
            Just to add more information to this problem, I tried this:

            Code:
                    	DateUtil.setShortDateDisplayFormatter(
                    			   new DateDisplayFormatter() { 
                    			           public String format(Date date) { 
                    			               if(date == null) return null; 
                    			              DateTimeFormat dateFormatter = DateTimeFormat.getFormat("YYYY-MM-DD HH:mm:SS"); 
                    			              String format = dateFormatter.format(date); return format; 
                    			          } 
                    			});
            But no impact.

            And of course you can't set a datetime formatter on a ListGridField. Nor can you do this:

            Code:
                	myListGrid.setDatetimeFormatter(new DateDisplayFormatter() { 
            	           public String format(Date date) { 
            	               if(date == null) return null; 
            	              DateTimeFormat dateFormatter = DateTimeFormat.getFormat("YYYY-MM-DD HH:mm:SS"); 
            	              String format = dateFormatter.format(date); return format; 
            	          } 
            	});
            Last edited by kieser; 11 Feb 2010, 09:12.

            Comment


              #7
              Are you possibly overriding the format somewhere else? If you don't think so, can you post a standalone test case?

              Comment


                #8
                I don't see that the formatting has been overwritten anywhere. Setting up a standalone test will be difficult but I will try. Problem is that this has a database back end providing the data.

                Is there anyway in the developer's console that I can check what the formatter is for the ListGrid?

                Comment


                  #9
                  If the API is broken, you won't need your database involved to show it. A clientOnly DataSource is fine.

                  Comment


                    #10
                    Just a followup to this. When I set the format to anything other than TOSERIALIZEABLEDATE, the date AND time display (where the format dictates that both should).

                    So this is definitely not a data problem. It's specifically that TOSERIALIZEABLEDATE is broken. It lacks the time component.

                    Also, there is a bug in the documentation because it states that you can supply a function in the call to setDateFormatter.

                    This is wrong. You are limited to the enum only. So only those predefined values for DateDisplayFormat.

                    Comment


                      #11
                      The built-in formats are, in general, not sensitive to whether something there is a type declaration of date or datetime. You just set the format you want.

                      By setting it to "a function", the docs are referring to providing a DateDisplayFormatter.

                      Comment


                        #12
                        Hi I am using SmartGwt 2.3 build 1400 and Gwt 2.0.4 on FF 3.6.10.
                        I have similar problem to this thread but concernig DateTimeItem (for list grid fields all works fine). I need to display date in DateTimeItem in format "yyyy-MM-dd HH:mm:ss" According to javadocs it should be enough to call setDateDisplayFormat(DateDisplayFormat.TOSERIALIZEABLEDATE), but the time part is missing. When I use e.g DateDisplayFormat.TOJAPANSHORTDATETIME the time part fo the date is displayed.
                        Setting global:
                        Code:
                        		DateUtil.setNormalDateDisplayFormatter(new DateDisplayFormatter() {
                        			
                        			@Override
                        			public String format(Date date) {
                        				DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
                        				return dtf.format(date);
                        			}
                        		});
                        has no effect on this fields
                        There is any possibility to set DateFormater function like for listgrid fields ?
                        I have tried to workaround this problem by adding additional TimeItem field to form, but there is one trick: time is diplayed properly but when user chooses another date, TimeItem field is not cleared. It happens only after form saving, which is annoing to users.
                        Thanks for help in advance

                        Comment


                          #13
                          All data format exchanger under one root thatz "Document collaboration" check it out
                          http://documentcollaboration.org/content/online-document-collaboration

                          Comment


                            #14
                            Any updates to this?

                            I want to do the same thing, which is format a ListGridField to be "yyyy-MM-dd HH:mm:ss". From what I've tried and gathered on this thread

                            - Calling ListGridField.setDateFormatter(DateDisplayFormat.TOSERIALIZEABLEDATE) does not display the time
                            - There is no ListGridField.setDateFormatter(DateDisplayFormatter) nor ListGrid.setDateFormatter(DateDisplayFormatter) method to use/define our own DateDisplayFormatter
                            - Calling DateUtil.setNormalDateDisplayFormatter() and/or DateUtil.setShortlDateDisplayFormatter has no affect on ListGridFields

                            Comment


                              #15
                              We've just added an API which should allow you to do this - as of the next nightly build, in addition to DateUtil.setShortDateDisplayFormat() and setShortDateDisplayFormatter() there will be DateUtil.setShortDatetimeDisplayFormat() and setShortDatetimeDisplayFormatter().

                              If you call DateUtil.setShortDatetimeDisplayFormat(DateDisplayFormat.TOJAPANSHORTDATETIME);
                              You should get your datetime fields displayed in the format you need in ListGrid fields.

                              Let us know if it doesn't work for you

                              Thanks and Regards
                              Isomorphic Software

                              Comment

                              Working...
                              X