Announcement

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

    Is there any timeline for java8 datetime API support?

    We have spent some time recently upgrading a lot of serverside third-party libraries, as well as to Java 8.

    I noticed that you could not return the new Date API classes, such as LocalDate, ZonedDateTime etc. in Datasource transfer objects, it becomes [object] in the client.

    So, i was wondering if there are any plans to support the java 8 Date API, and if so, when?

    #2
    Support for these classes was added a while ago; you may have an older build if you are seeing these date and time objects translated as plain JS objects.

    Comment


      #3
      OK! I am running 6.0-p20171202. I take it it has been added after that?

      Comment


        #4
        Correct.

        Comment


          #5
          Hey there, some follow up questions here, quite a bit later...

          1. Do you know when it was added? We purchased a new license a while ago that we, believe it or not, simply haven't had time to update to... (day has 24 hours etc.)

          2. How does it work, are all date-related criteria parameters just using java8 classes now, or is there some setting somewhere that you have to define? For example if i want Smartgwt to always return LocalDateTime for a fetch operation?

          Thankful for input. Cheers,

          Comment


            #6
            It's present on 6.0 and later branches.

            As far as how it works, if you produce these types, whether it's because of your JDBC driver for SQL DataSources, or because you have a Hibernate bean where a bean property has one of these types, then they are simply translated to the client as you would expect, and translated from client to server likewise. No settings are required.

            Comment


              #7
              Right. How about stuff like criteria parameters, or getting things out of the valueMap?

              Comment


                #8
                We've made some changes in support for Java8 Date/Time API. They will be available for download in nightly builds since Mar 7 (tomorrow). Let us know please if you have any problems.

                Comment


                  #9
                  Missed this. Great! May i ask where these changes documented, for example if i can specify that i want LocalDates for an criteria date parameter in a valuemap?

                  Comment


                    #10
                    To clarify:

                    One use case is several places where i have a non-datasourcebound DateChooser for users to select date periods, for example when requesting reports. When the user clicks on the submit button, i take the values from the DateChooser and submit them as part of a DSRequest as Criteria.

                    When i extract the criteria values server-side, they are java.util.Dates. I would like them to be LocalDate. Is this possible?

                    Comment


                      #11
                      If you are targeting a DataSource and the field is declared, you should be able to use dataSourceField.javaClass to get the type you want.

                      Comment


                        #12
                        Yes i realize that, but as i wrote above this is a non-datasourcebound Date Criteria in a DSRequest which i use for server-side filtering, in fetch-operations . So they will always be dates? I could imagine some generic setting on the datasource, or in a config file, either per datasource or global.

                        Comment


                          #13
                          Well, perhaps there could be some kind of API that takes an inbound DSRequest and interprets it with respect to a declaration of which fields should have which type.. but a DataSource is exactly that.. so it seems like the system already supports what you want?

                          As far as a global setting for decoding any XML, that would just break all existing processing of dates, so not an option.

                          Comment


                            #14
                            OK, perhaps i have misunderstood some functionality. I have a custom datasource that you call the fetch-operation on.

                            When the user clicks "get report", i read the value of the DateChooser and put together a Criteria:
                            Code:
                            final Criteria c = new Criteria();
                            c.addCriteria("begin", beginChooser.getData());//getData() in DateChooser return java.util.Date
                             c.addCriteria("end", endChooser.getData());
                            I use this as criteria when i call myGrid.fetchData();

                            Then, on the server i get the Date out of the Criteria map. Those values are also java.util.dates. I use these to call my service methods and get the correct data out.

                            When fetching data, there is no DataSource field i can look at, so i'm not sure what you mean? I wrote this a long time ago, so if there's a better way for me to do this i'm all ears.

                            Comment


                              #15
                              If myGrid.dataSource has fields "begin" and "end" and you use the javaClass attribute on them, you should find that when you retrieve the criteria on the server, you get instances of your declared javaClass instead of normal java.util.Date instances.

                              Comment

                              Working...
                              X