Tuesday, March 22, 2016

Re: Why can I not extend java.util.Date?

1) Dates are very, very, very hard.  Calendar idiosyncrasies, time zones, leap seconds...  Be 100% sure you need to actually extend Date before messing with it.
2) You are probably better off putting your method (presuming this is the only one) in a custom utility class instead of extending Date so you don't alter the functionality of any other libraries you use that aren't expecting DOW to be non-standard.
getCustomDay(Date date) {
if (date.getDay() == 0)
    return 7;
return date.getDay();

On Sunday, March 20, 2016 at 12:24:09 PM UTC-5, Stefan Falk wrote:
Working with Date is a nightmare.. so beforehand: Any advice regarding work with time and date in GWT are very welcome!

Why do my requests silently fail if I do this:

public class AwesomeDate extends java.util.Date {

  public final static int MONDAY = 1; 
  public final static int TUESDAY = 2; 
  public final static int WEDNESDAY = 3; 
  public final static int THURSDAY = 4; 
  public final static int FRIDAY = 5; 
  public final static int SATURDAY = 6; 
  public final static int SUNDAY = 7;

  public int getDay() { 
    switch(super.getDay()) { 
    case 1:
      return MONDAY;
    case 2:
      return TUESDAY;
    case 3:
      return WEDNESDAY;
    case 4:
      return THURSDAY;
    case 5:
      return FRIDAY;
    case 6:
    return SATURDAY;
      case 0:
      return SUNDAY;
    throw new RuntimeException();

and then

AwesomeDate fromDate = ..
AwesomeDate toDate = ..

myObjectEnter.request(fromDate, toDate, onSuccess, onFailure);


MyObject#request(Date from, Date to, OnSuccess<ResultDTO> success, OnFailure failure);

Because if I do that my request does simply nothing. It's not even getting sent off.. I have an object that takes care for parallel requests

 for (ParallelizableRequest<?> parallelizableRequest : this.childRequests) {

but that request that is using AwesomeDate is simply not being executed. In the JavaScript debugger I see that the list childRequests contains two elements but that's all I can tell.

Any ideas?

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