mirror of
https://github.com/google/nomulus.git
synced 2025-07-19 17:26:09 +02:00
Use a SQL date object for LocalDates (#842)
* Use a SQL date object for LocalDates * Clean up comment
This commit is contained in:
parent
7f87938942
commit
12ec54f56c
12 changed files with 3325 additions and 3278 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue