1
0
mirror of https://github.com/google/nomulus synced 2026-01-03 11:45:39 +00:00

Use a SQL date object for LocalDates (#842)

* Use a SQL date object for LocalDates

* Clean up comment
This commit is contained in:
gbrodman
2020-10-20 15:44:23 -04:00
committed by GitHub
parent 4d5d9700b8
commit 0b73e9032c
12 changed files with 3325 additions and 3278 deletions

View File

@@ -24,6 +24,7 @@ import java.time.ZonedDateTime;
import java.util.TimeZone;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
/** Utilities methods and constants related to Joda {@link DateTime} objects. */
public class DateTimeUtils {
@@ -108,4 +109,12 @@ public class DateTimeUtils {
zonedDateTime.toInstant().toEpochMilli(),
DateTimeZone.forTimeZone(TimeZone.getTimeZone(zonedDateTime.getZone())));
}
public static java.sql.Date toSqlDate(LocalDate localDate) {
return new java.sql.Date(localDate.toDateTimeAtStartOfDay().getMillis());
}
public static LocalDate toLocalDate(java.sql.Date date) {
return new LocalDate(date.getTime(), DateTimeZone.UTC);
}
}