Announcement

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

    DetailViewer Date Format

    SmartClient Version: v8.3p_2013-03-20/PowerEdition Deployment (built 2013-03-20)

    I have a requirement to display DetailViewer fields using a date format of "dd-MMM-yy".

    I attempted to apply the date format globally within the application with the following logic in the onModuleLoad() method.

    Code:
    DateUtil.setNormalDateDisplayFormatter(new DateDisplayFormatter()
            {
                public String format(Date aDate)
                {
                    if (aDate == null)
                        return null;
                    else
                        return DateTimeFormat.getFormat("dd-MMM-yy").format(aDate);
                }
            });
    Unfortunately, the DetailViewer did not honor the format. See attached for further details.

    What is the proper way to set the date format for a data source field in the DetailViewer?

    Thanks.
    Attached Files

    #2
    Most likely, you are providing the dates as Strings in your Java code, rather than Date instances. They must be provided as Date instances or formatting settings will not apply.

    Comment


      #3
      Using the Developer Console and enabling Track RPC, I captured the following. The 'last_modified' field seems to be properly typed.

      Code:
      [
          {
              data:[
                  {
                      last_modified:new Date(1261414800000), 
                      title:"000317 SmartCaddy - User Manual", 
                      ai_classification:"", 
                      modified_by:"Bea Müller", 
                      nsd_file_name:"", 
                      description:"", 
                      ai_id:"852481CF00854DA3BFF1D5606654BB67", 
                      author_s:"", 
                      ai_file_name:"Smartcaddy-Manual.pdf", 
                      ai_owned_by_id_keyed:"", 
                      ai_native_file:"", 
                      ai_config_id:"0C27A702DE504287BFE441CEEA8A6344", 
                      status:"", 
                      ai_change_reason:"", 
                      ai_viewable_file:"", 
                      content:"07.10.2009 10:55:30 7 smartcaddy Teilebeschreibung - bluestar Mobile <em style=\"background-color: #FFF; color: #A04; font-weight: bold;\">Golf</em> Scorer Abnehmbar z.B. bei Turnieren Touchscreen GPS - Distanzmessung zum Grn und zu Hindernissen GPS - Schlagweitenmessung Lernfhig auf Hindernisse Elektronische Scorecard Alle| mit der LED gestoppt wird, setzt eine Bergab-Bremse ein. Diese ist nicht fr steile Berge zu benutzen. Anleitung_Smartcaddy-Bluestar_290709_end.indd 21 07.10.2009 10:55:44 22 smartcaddy GPS - Mobile <em style=\"background-color: #FFF; color: #A04; font-weight: bold;\">Golf</em> Scorer inkl. Straennavigation GPS - Mobile <em style=\"background-color: #FFF; color: #A04; font-weight: bold;\">Golf</em>| 2110 inkl. Europa - Straenkarte Alle Pltze von Deutschland, sterreich und der Schweiz Individualisierung ber Google Earth Mobile <em style=\"background-color: #FFF; color: #A04; font-weight: bold;\">Golf</em> Scorer ist ein eingetragenes Warenzeichen von Andreas Lachner. Anleitung_Smartcaddy-Bluestar_290709_end.indd 22", 
                      ai_file_size:560785, 
                      ai_file_id:"0C27A702DE504287BFE441CEEA8A6344", 
                      ai_type:"Document"
                  }
              ], 
              endRow:-1, 
              invalidateCache:false, 
              isDSResponse:true, 
              operationType:"fetch", 
              queueStatus:0, 
              startRow:0, 
              status:0, 
              totalRows:34
          }
      ]
      I know the DetailViewer has a setDateFormatter() method, but I could not find a constant that matches "dd-MMM-yy".

      Thoughts?

      Comment


        #4
        Hoping for some feedback on previous reply.

        Thoughts?

        Comment


          #5
          We were about to try reproducing this, but then noticed - you're setting the "normal" formatter. For a "date" field, DetailViewer uses the "short" formatter. All the "normal" formatters would show the time value, which doesn't apply to a "date" field.

          Comment


            #6
            That worked - thank you.

            The corrected code fragment is below.

            Code:
            DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter()
                    {
                        public String format(Date aDate)
                        {
                            if (aDate == null)
                                return null;
                            else
                                return DateTimeFormat.getFormat("dd-MMM-yy").format(aDate);
                        }
                    });

            Comment

            Working...
            X