-
Notifications
You must be signed in to change notification settings - Fork 65
Add conversion to old java.util.Calendar #705
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
Comments
I think this would be a nice convenience. What is best approach for going from java.util.Calendar to a PlainDate? or from Moment to a properly zoned java.util.Calendar? Forgive me if this is really straightforward (dumb question). I need to be confident I'm using it right. For example, I've got a snippet that looks like... How to complete it?
|
Thanks for your interest. First let me explain some things about the calendar date input (indicated by first generic type parameter Its date value (expressed by year, month, day-of-month) has to be interpreted as local calendar date at given geographical longitude. The algorithms I have implemented so far use this calendar date at noon time and longitude to calculate an approximation of sunrise/sunset before refining it up to minute precision. Important is to understand that the timezone is not really in play during this first step of calculation. The date is like a longitudinal date, but the longitudinal zone offset is generally not the same as civil timezone offset. Of course, if we choose a timezone which yields finally the same calendar date at given geographical longitude then we are fine (especially at noon time). And if the input to the suntime-calculators in Time4J is just a plain date (for example the gregorian type Just for the records: This subtile difference between longitudinal date and civil-timezone-related date is relevant for example in the issue raised in the suntime-library of Mike Reedell. And sure, the resulting sunset can happen on another civil date than the local date for which the sunset was searched/wanted. This is simply due to the difference between longitudinal offset and civil tz-offset. So you might ask when Time4J applies the civil timezone? It is the last step after you have already calculated the sunrise/sunset-event as So let's now return to the original question how to convert Your interface
Maybe this is the safest approach to defend against users who chose let's say "America/New_York" as timezone and look for the sunrise-event anywhere in Australia... |
An extra conversion between the classes |
Enhance the class
TemporalType
by a new constant:The text was updated successfully, but these errors were encountered: