Other option could be to store dates using server's timezone but retaining the time and date portion coming from the client. I.e. if user accesses facility on 12/01 at 1:30 am GMT-5, and the server time is GMT+2, the resulting date stored in database would be 12/01 at 1:30 am GMT+2. And assuming that all dates in the database (on server side) will be against the same GMT offset, the report statistics will be always showing the same results.
Common way of implementing this approach is to replace Date serializer with custom version which ignores timezone during serialization/ deserializaion. This would require gwt recompilation, which might not be the best thing to do. On Dec 15, 12:47 pm, Sydney <[email protected]> wrote: > Well not much response on that topic, so let me explain in a better way my > problem. I have the class Facility in shared folder (client and server). > > public class Facility { > private List<Log> logs; > // getter, setter > > } > > public class Log { > private Date date; > // getter, setter > > } > > I would like to run this method server side. Right now it does not take > account for locale and is a method of Facility: > > public Map<String, Integer> countAccess() { > SimpleDateFormat smf = new SimpleDateFormat("M"); > Map<String, Integer> mapAccess = new HashMap<String, Integer>(); > for(Log log: logs) { > String currentMonth = smf.format(log.getDate()); > Integer count = mapAccess.get(currentMonth); > if(count == null) { > count = 1; > } > mapAccess.put(currentMonth, count); > } > return mapAccess; > > } > > The facility has been accessed only once on 12/01/10 at 1:30 GMT, several > users would have different report: > locale en-US: November 1, December 0 > locale fr-FR: Novembre 0, Decembre 1 > > 1/ I understand that to use this algorithm it needs to be executed on the > server side, but the method is part of an object Facility that can be shared > client and server side. Where should I put this method to be able to run it > on the server side? Also this version does not use any locale, so how can I > get the client locale? > > 2/ Another solution is to return the list of date and run the algorithm on > the client side by using DateTimeFormat but I am wondering if it's a good > solution since you have to send a lot of data over the wire. > > Thanks -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
