[threeten-dev] [threeten-develop] Integration with other JDK classes
Douglas Surber
douglas.surber at oracle.com
Wed Dec 5 10:10:00 PST 2012
Stephen,
Can you confirm that all of the following work in your proposal?
LocalTime t1 = LocalTime.from(aJavaSqlTime);
LocalTime t2 = LocalTime.from(aJavaSqlTimestamp);
LocalDate t3 = LocalDate.from(aJavaSqlDate);
LocalDate t4 = LocalDate.from(aJavaSqlTimestamp);
LocalDateTime t5 = LocalDateTime.from(aJavaSqlTimestamp);
With the addition methods
java.sql.Time t6 = java.sql.Time.from(aLocalTime);
java.sql.Date t7 = java.sql.Date.from(aLocalDate);
java.sql.Timestamp t8 = java.sql.Timestamp.from(aLocalDateTime);
java.sql.Timestamp t9 = java.sql.Timestamp.from(anOffsetDateTime);
java.sql.Timestamp t10 = java.sql.Timestamp.from(aZonedDateTime);
I guess these would work as well.
java.sql.Time t11 = java.sql.Time.from(aLocalDateTime);
java.sql.Time t12 = java.sql.Time.from(anOffsetDateTime);
java.sql.Time t13 = java.sql.Time.from(aZonedDateTime);
java.sql.Date t14 = java.sql.Date.from(aLocalDateTime);
java.sql.Date t15 = java.sql.Date.from(anOffsetDateTime);
java.sql.Date t16 = java.sql.Date.from(aZonedDateTime);
What happens with these?
OffsetDateTime t17 = OffsetDateTime.from(aJavaSqlTimestamp);
ZonedDateTime t18 = ZonedDateTime.from(aJavaSqlTimestamp);
I would expect them to fail as java.sql.Timestamp does not have an
offset or zone id.
Thanks.
Douglas
At 06:46 AM 12/5/2012, Stephen Colebourne wrote:
>The question is to what degree should existing JDK date/time classes
>support integration with 310?
>Key open question to everyone is how much integration should be
>done?
>
>Here is my list and proposls:
>util.Date - implement DateTimeAccessor (INSTANT_SECONDS and
>fractional
>second fields)
>sql.Date - implement DateTimeAccessor (EPOCH_DAY and related)
>sql.Time - implement DateTimeAccessor (NANO_OF_DAY and related)
>sql.Timestamp - implement DateTimeAccessor (all ChronoField)
>Calendar - implement DateTimeAccessor (all ChronoField)
>GregorianCalendar - implement DateTimeAccessor (all ChronoField and
>zone)
>FileTime should implement DateTimeAccessor
>xml.XMLGregorianCalendar should implement DateTimeAccessor
>xml.Duration should implement PlusAdjuster and MinusAdjuster
>TimeUnit should implement PeriodUnit
>
>In addition, some common additional methods would be very helpful:
>Date.toInstant()
>util.Date.from(DateTimeAccessor)
>sql.Date.from(DateTimeAccessor)
>sql.Time.from(DateTimeAccessor)
>sql.Timestamp.from(DateTimeAccessor)
>Calendar.toInstant()
>Calendar.from(DateTimeAccessor)
>GregorianCalendar.toZonedDateTime()
>GregorianCalendar.from(DateTimeAccessor)
>
>GregorianCalendar might beneft from toLocalDate() and toLocalTime().
>
>The sql subtypes of util.Date are of course troublesome. The JDBC
>group need to advise on whether they consider them effectively
>deprecated or not.
>
>DAYS in TimeUnit will be different to DAYS in ChronoUnit as it is
>exactly 24 hours.
>
>I think that is all the JDK date/time classes. I could be wrong...
>
>Stephen
>(This was a private discussion being made public)
>
>------------------------------------------------------------------------------
>LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
>Remotely access PCs and mobile devices and provide instant support
>Improve your efficiency, and focus on delivering more value-add
>services
>Discover what IT Professionals Know. Rescue delivers
>http://p.sf.net/sfu/logmein_12329d2d
>_______________________________________________
>threeten-develop mailing list
>threeten-develop at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/threeten-develop
More information about the threeten-dev
mailing list