On Thursday, March 24, 2016 at 2:25:09 PM UTC+1, Stefan Falk wrote:
My main problem here is that on the server side everything is following the ISO standard MONDAY = 1, TUESDAY = 2, .. etc and since we only got Date on he client things can get mixed up. This is why I thought I could wrap/extend Date and just override the getDay() method in order to
- have the mapping exactly where I need it and
You're breaking the Liskov substitution principle. This is not good OOP, don't do it.
- get rid of all the deprecation warnings in my code as I use only MyDate
How about using a MyDate that can do whatever you want it to do by wrapping a JsDate or Date (or just a double), possibly providing a toDate() returning a java.util.Date for those places where you need it (formatting, etc.)
That MyDate can still be serializable (assuming your problem here is GWT-RPC serialization), either directly (if wrapping a Date or double) or through a CustomFieldSerializer.
Or you could *add* a new method to your subclass to avoid changing the java.util.Date contract. As for GWT-RPC serialization, if extending java.util.Date, you'll have to provide a CustomFieldSerializer (just copy the com.google.gwt.user.client.rpc.core.java.util.Date_CustomFieldSerializer and use your own class instead)
Speaking of Date .. will there actually be support for all of the fancy Date/Time stuff that came with Java 8? Again, like you said, working with Dates is very hard sometimes so imho it would be very important to get there with GWT. But I understand that this might also not be that easy and it must have a particular reason why it's not yet there.
Reason number 1 is "it's a whole lot of work".
I suppose ThreeTen or ThreeTenBP can be used as a starting point (friendly licensing), but there'd still be a lot of code that'd need to be deleted and/or adapted.
It's more important to get java.util.function and java.util.stream in (ongoing work) than java.time.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment