[threeten-dev] Calendar.toZonedDateTime?
Xueming Shen
xueming.shen at oracle.com
Wed Jun 26 13:56:01 PDT 2013
On 06/26/2013 12:43 PM, Stephen Colebourne wrote:
> Its a little hard for me to tell what current methods we have.
>
> We seem to have
> Calendar.toInstant()
> GregCal.toZDT()
> GregCal.from(ZDT)
>
> I'm surprised I couldn't see a Calendar.from() method.
> Calendar.from(ChronoZonedDateTime) would make most sense
>
The reason we did not do a Calendar<->ChronoZonedDateTime is mainly
Calendar is an abstract class and in theory the ChronozonedDateTime can
be a non-built-in one. That said, if it's desired that class mapping can be
added.
-Sherman
> And as suggested,
> Calendar.toZonedDateTime() returning ChronoZonedDateTime
> (using covariant return types in GregCal to return ZonedDateTime)
> It would have to handle chronology to calendar class mapping.
>
> In addition, the Calendar.Builder should have a setInstant(Instant)
> method, as it looks odd to have two setInstant() methods, neither of
> which actually take an Instant!
>
> Stephen
>
>
> On 26 June 2013 20:05, roger riggs<roger.riggs at oracle.com> wrote:
>> Should it be possible to convert any java.util.Calendar object to a
>> ZonedDateTime?
>> The conversion works from an Instant and a TimeZone both found in Calendar.
>>
>> The current placement of toZonedDateTime in GregorianCalendar does not allow
>> it to be used with some calendars, for example a Japanese Imperial Calendar
>> is not of type GregorianCalendar.
>>
>> Could toZonedDateTime be moved up the Calendar?
>>
>> Roger
>>
>>
More information about the threeten-dev
mailing list