From a602f34ec4b845a442b1152e02d655c4cd200acf Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 5 Sep 2007 00:07:58 +0000 Subject: More fixes for adapting SQL dates. --- .../amazon/carbonado/adapter/DateTimeAdapter.java | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/main') diff --git a/src/main/java/com/amazon/carbonado/adapter/DateTimeAdapter.java b/src/main/java/com/amazon/carbonado/adapter/DateTimeAdapter.java index c1119ac..fc12319 100644 --- a/src/main/java/com/amazon/carbonado/adapter/DateTimeAdapter.java +++ b/src/main/java/com/amazon/carbonado/adapter/DateTimeAdapter.java @@ -174,6 +174,18 @@ public @interface DateTimeAdapter { return date == null ? null : new DateTime(date, mZone); } + public DateTime adaptToDateTime(java.sql.Date date) { + return date == null ? null : new DateTime(date.getTime(), mZone); + } + + public DateTime adaptToDateTime(Time time) { + return time == null ? null : new DateTime(time.getTime(), mZone); + } + + public DateTime adaptToDateTime(Timestamp timestamp) { + return timestamp == null ? null : new DateTime(timestamp.getTime(), mZone); + } + // Adapt to DateMidnight... public DateMidnight adaptToDateMidnight(long instant) { @@ -192,6 +204,18 @@ public @interface DateTimeAdapter { return date == null ? null : new DateMidnight(date, mZone); } + public DateMidnight adaptToDateMidnight(java.sql.Date date) { + return date == null ? null : new DateMidnight(date.getTime(), mZone); + } + + public DateMidnight adaptToDateMidnight(Time time) { + return time == null ? null : new DateMidnight(time.getTime(), mZone); + } + + public DateMidnight adaptToDateMidnight(Timestamp timestamp) { + return timestamp == null ? null : new DateMidnight(timestamp.getTime(), mZone); + } + // Adapt to LocalDateTime... public LocalDateTime adaptToLocalDateTime(long instant) { @@ -210,6 +234,18 @@ public @interface DateTimeAdapter { return date == null ? null : new LocalDateTime(date, mZone); } + public LocalDateTime adaptToLocalDateTime(java.sql.Date date) { + return date == null ? null : new LocalDateTime(date.getTime(), mZone); + } + + public LocalDateTime adaptToLocalDateTime(Time time) { + return time == null ? null : new LocalDateTime(time.getTime(), mZone); + } + + public LocalDateTime adaptToLocalDateTime(Timestamp timestamp) { + return timestamp == null ? null : new LocalDateTime(timestamp.getTime(), mZone); + } + // Adapt to LocalDate... public LocalDate adaptToLocalDate(long instant) { @@ -228,6 +264,18 @@ public @interface DateTimeAdapter { return date == null ? null : new LocalDate(date, mZone); } + public LocalDate adaptToLocalDate(java.sql.Date date) { + return date == null ? null : new LocalDate(date.getTime(), mZone); + } + + public LocalDate adaptToLocalDate(Time time) { + return time == null ? null : new LocalDate(time.getTime(), mZone); + } + + public LocalDate adaptToLocalDate(Timestamp timestamp) { + return timestamp == null ? null : new LocalDate(timestamp.getTime(), mZone); + } + // Adapt from DateTime and DateMidnight... (accept the more generic ReadableInstant) public long adaptToLong(ReadableInstant instant) { -- cgit v1.2.3