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
The LocalDateTime(Object instant, DateTimeZone zone) constructor ignores the timezone #454
Comments
The final piece of code is incorrect. It uses By passing local in where instant is expected, you implicitly convert the local millis to instant millis based on UTC, whereas you need to pass in the correct instant millis for Athens, which is 2 hours different. eg.
|
That is my mistake. I don't fully understand the difference between instant
and local, it seems.
However, that doesn't answer my question: is there a bug in the new
LocalDateTime(Object, DateTimeZone)? This constructor seems to set the time
zone to UTC.
Kind regards,
Bogdan C.
vin., 24 nov. 2017, 15:53 Stephen Colebourne <notifications@github.com> a
scris:
Closed #454 <#454>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#454 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AQCOjaMvLASIH0jO5jjMD-HBXqQX1ciMks5s5spfgaJpZM4QpzvB>
.
--
|
No, there is no bug. In order to perform calculations on local millis, the code uses the UTC version of the chronology. Its an internal detail, and correct. |
Thank you very much for your quick answers. Why do I get the same result while printing, to the console, the objects created below?
Kind regards, |
What are your thoughts about this? |
Hi, Would you, please, look into my last question / test case? Thank you very much |
Any chance you can post your opinion about the last use case? |
I see the problem - you expect the new This can also be worked around, along the lines of Its also important to bear in mind that Joda-Time has been replaced by |
Huh, I thought you would never answer. But you did and you did it in a diplomatic way. I understand and I agree with you that, at this point, you can't do anything about it. Have a great day forward! |
Key information
Joda-Time version:
2.9.3
Result of
TimeZone.getDefault()
sun.util.calendar.ZoneInfo[id="Europe/Athens",offset=7200000,dstSavings=3600000,useDaylight=true,transitions=138,lastRule=java.util.SimpleTimeZone[id=Europe/Athens,offset=7200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
Result of
DateTimeZone.getDefault()
Europe/Athens
Problem description
The LocalDateTime(Object instant, DateTimeZone zone) constructor ignores the timezone due to iChronology = chronology.withUTC();
The somewhat analogue LocalDateTime(long instant, DateTimeZone zone) gives the answer considering the TimeZone.
Test case
new LocalDateTime(new LocalDateTime(2012, 1, 1, 0, 0), DateTimeZone.getDefault())
returns 2012-01-01T00:00:00.000
while....
new LocalDateTime(new LocalDateTime(2012, 1, 1, 0, 0).getLocalMillis(), DateTimeZone.getDefault())
returns 2012-01-01T02:00:00.000
The text was updated successfully, but these errors were encountered: