Announcement

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

    AdvancedCriteria DateTime saved format?

    I have setup custom DateTime formatting and parsing so that all our DateTimes are displayed in the with the timezone.

    I have made use of the DateUtil methods to specify both the formatting and parsing and it is all work very nicely. Forms with DateTimes show our format and using the picker works as well.

    All good. The issue I am having now is that when I use a DateTime in the FilterBuilder, it is showing our format as above but when I save the AdvancedCriteria the format of the DateTime is a different format and so when I load a saved Criteria, our date parsing fails because of the unknown format.

    For example, on the Filter Builder I select a DateTime using the picker to May 1st Midnight my timezone (Eastern) and the FilterBuilder shows me the expected DateTime in my format:

    2014-05-01 00:00:00 -0400

    When I save this AdvancedCriteria to a String via json, the format of the above date turns into this:

    2014-05-01T04:00:00.000

    I am not sure what this format is?

    Can I control the format of how the DateTime is persisted in the AdvancedCriteria?

    Thanks!

    #2
    That's XML Schema standard format for how datetime values should be serialized.

    See Date and Time Format and Storage for background on how dates are represented in memory and when serialized and/or transmitted to the server.

    Comment


      #3
      OK. Thanks for pointing me in the right direction.

      One further question, the doc states:

      "When sent or received in XML or JSON, datetime field values should be serialized out as full datetimes using the standard XML Schema datetime format (EG:2006-01-10T12:22:04-04:00). If no timezone offset is supplied, the value is assumed to be GMT/UTC. "

      When is the timezone included and when is it not included? In my case it is not being included and I am just trying to figure if I have any control over that or if SmartGWT is always using GMT/UTC and hence never includes the timezone in the ISO date format. I just want to know if I need to handle parsing with the timezone as well as without it.

      Thanks.

      Comment


        #4
        I have added to check the string and I just append the +00:00 to it if it needs it and that makes my parsing work fine now.

        I have one last issue now though. When I select a time as part of the picker, the input box shows the time that was selected but the label on the right shows 00:00:00 and the stored value does not have the time either. If I save and refresh I get all zeros for the time part.

        See attached image.

        Any ideas?
        Attached Files

        Comment


          #5
          When serializing, SmartClient always sends UTC and does not add a timezone offset. When parsing server responses, SmartClient will correctly parse a timezone offset if you include one.

          As far as your screenshot, we don't really have a speculation as to how that could occur, other than perhaps installing a parser that fails to read your formatted values.

          If that doesn't suggest a solution, we'll need to see how this problem can be reproduced.

          Comment


            #6
            What should I send you that shows the reproducible problem? Would you want working eclipse project that reproduces the problem?

            My parsing is working fine as I have GWT.log statements in that show it parses as expected and when I use a DateTimeItem on a form there are no issues and the values coming or going to the server. It is only the FilterBuilder that I am having a problem with.

            Curiously, when I select the date field in the FilterBuilder, it causes my formatter to be called 19 times:
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400
            [INFO] [sandbox] - Short - Formated date: Sun May 04 00:00:00 EDT 2014 -> 2014-05-04 00:00:00 -0400

            and then when I use the picker and select May 1st, 09:13 I get the following:

            [INFO] [sandbox] - Short - Formated date: Thu May 01 09:13:00 EDT 2014 -> 2014-05-01 09:13:00 -0400
            [INFO] [sandbox] - Parsed String (2014-05-01 09:13:00 -0400) using pattern (yyyy-MM-dd HH:mm:ss Z) into Date (Thu May 01 09:13:00 EDT 2014)
            [INFO] [sandbox] - Parsed String (2014-05-01 09:13:00 -0400) using pattern (yyyy-MM-dd HH:mm:ss Z) into Date (Thu May 01 09:13:00 EDT 2014)
            [INFO] [sandbox] - Short - Formated date: Thu May 01 00:00:00 EDT 2014 -> 2014-05-01 00:00:00 -0400

            I dunno where that last call to the Format is coming from but that is the culprit as it is passing in a date with zero'd out times.

            Anyway, let me know the best way to give you a reproducible sample. I have a separate eclipse project showing this. It has a little more stuff in it since I wanted to keep the same mechanisms in place that we are using (custom DataSource, in this case passing back dummy data).

            Comment


              #7
              Having a field containing Datetime data which is defined as type Date somewhere could be responsible for the time information being dropped by the format / parse cycle.
              It's hard to comment more specifically without seeing the problem.

              The best way to show us your sample would be to show us the minimal code to reproduce which we can drop into our own Eclipse project. So typically - a minimal EntryPoint class which defines and draws the components needed to cause the problem, plus ds.xml file for the dataSource and if you have custom server code required to support the entry point, this as well (also - stripped down to the bare minimum required to reproduce the problem).

              Basically we need something we can run on our end which demonstrates the problem and doesn't include any seemingly unrelated extraneous code!
              Oh - and clear idiotproof steps to reproduce so we can be sure we're not making incorrect assumptions about exactly how you are interacting with the application.

              Thanks!
              Isomorphic Software

              Comment


                #8
                Working on that now. How shall I send/upload this to you?

                Comment


                  #9
                  Since it's generally going to be just a single .java file, just attach it here on the forums.

                  Comment


                    #10
                    Even though I have shrunk it down considerably, it is hard to get it down to a single java file unless I really hack it to pieces which I can.

                    Right now I have it calling into a dummy custom ds on the server that returns fake data. guess that needs to be done differently in this case then.

                    Comment


                      #11
                      You're doing far more work than you need to. It's vanishingly unlikely that this is an issue that involves both client and server, so you can just lift a clientOnly DataSource from any sample, or just take a sample and add in your formatter/parse declarations.

                      Comment


                        #12
                        Attached is the single java class, ds.xml and the web.xml I used. Let me know if I missed anything.

                        When running in development mode you will see the GWT.log messages I have w/r to formatting and parsing dates.

                        When loaded, select the "Created At (DT)" field as this is the one defined as "datetime". Click the picker and set the hour & minutes and then select a date. You will see the correct date in the input box formatted to display the timezone. The calculated field will have the time all zeros. The criteria also as all zeros, you can click filter and see in the GWT log the content of the filter.

                        If i edit the input field directly and put in hours minutes and seconds, only the seconds show up in the calculated field. The hours & minutes remain 00.

                        Thanks.
                        Attached Files
                        Last edited by stonebranch1; 5 May 2014, 17:59. Reason: typo

                        Comment


                          #13
                          I am working on an even simpler way of reproducing the problem which will be easier to use. Will post it in a few minutes...

                          Attached.
                          Attached Files
                          Last edited by stonebranch1; 6 May 2014, 07:07. Reason: Adding attachement

                          Comment


                            #14
                            It is related to the format showing the timezone via the format:

                            "yyyy-MM-dd HH:mm:ss Z" which displays like this: "2014-05-05 15:25:26 -0400"

                            If I change the format to: "yyyy-MM-dd HH:mm:ss" it works fine.

                            What I don't understand is that I have the format and parsing to go both ways that does handle the timezone so not sure why it breaks when timezone is used.

                            Comment


                              #15
                              Yes, we see the issue and are looking into the best way to address it.

                              Comment

                              Working...
                              X