-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testDateMidnightSerWithTypeInfo test dependent on $TZ #49
Comments
Good question, I was wondering the same myself. I don't know the answer at this point. |
Hmmh. I haven't been able to reproduce the failure, even with trying to set different TZ for JVM as per: http://stackoverflow.com/questions/2493749/how-to-set-a-jvm-timezone-properly so I think I could use some help if anyone knows good invocation. |
Hi all, System.out.println("Default time zone: " + DateTimeZone.getDefault().getID());
DateMidnight dateInUtc = new DateMidnight(2001, 1, 22, DateTimeZone.UTC);
System.out.println("Milis for UTC: " + dateInUtc.getMillis());
DateMidnight dateInLocal = new DateMidnight(2001, 1, 22);
System.out.println("Milis for local: " + dateInLocal.getMillis()); Above prints: Default time zone: Europe/Warsaw
Milis for UTC: 980121600000
Milis for local: 980118000000 When we use constructor with time zone it will be used to create chronology class - Everything looks ok until chrono = selectChronology(chrono); In my opinion this changing of time zone causes this bug. I am not sure, this is just my assumption. Let me know what do you think about it. Best regards, |
@ZioberMichal sounds plausible yes. The underlying question is then whether test needs to make sure proper TZ is used, or whether |
@cowtowncoder I think that it depends from DateTimeFormatter contract. If this class work in this way when we do not pass TZ then we should set TZ and problem will be resolved. Another question is maybe DateTimeFormatter which is created by this module should be created in different way in this case. I will try to debug this when I find some time. |
@ZioberMichal Appreciate your help here. @zkiss what do you think would make sense here? |
@cowtowncoder I made some other tests and I think that main problem is linked with the fact that DateMidnight date = new DateMidnight(2001, 1, 22);
DateMidnight dateInUTC = new DateMidnight(2001, 1, 22, DateTimeZone.UTC);
DateTimeFormatter DEFAULT_JODA_DATEONLY_FORMAT
= ISODateTimeFormat.date().withZoneUTC();
System.out.println(DEFAULT_JODA_DATEONLY_FORMAT.print(date));
System.out.println(DEFAULT_JODA_DATEONLY_FORMAT.print(dateInUTC)); prints 2001-01-21
2001-01-22 Test 2: DateMidnight date = new DateMidnight(2001, 1, 22);
DateMidnight dateInUTC = new DateMidnight(2001, 1, 22, DateTimeZone.UTC);
DateTimeFormatter DEFAULT_JODA_DATEONLY_FORMAT
= ISODateTimeFormat.date();
System.out.println(DEFAULT_JODA_DATEONLY_FORMAT.print(date));
System.out.println(DEFAULT_JODA_DATEONLY_FORMAT.print(dateInUTC)); prints 2001-01-22
2001-01-22 As you can see when formatter is created with |
I have created small proposition how to fix this. I am not sure whether I have noticed all side effects of my changes but maybe this will help you to fix this in much better way. |
Ok, let's see what happens. While I worry about compatibility, we also do want to get things improved, tests stable. |
@cowtowncoder @ZioberMichal sorry I've missed this, I have limited internet access at the moment. |
Hi there. I'm running into a problem with the test suite. It doesn't pass unless the $TZ environment variable is set to "GMT":
Could this be a bug in the code, or just an unexpected external dependency in the test suite?
Regards,
Tim.
The text was updated successfully, but these errors were encountered: