mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 02:36:03 +02:00
Remove ofy support from auto timestamp classes (#1708)
Also remove the use of ZonedDateTime, as joda DateTime can already be persisted to SQL with an existing converted.
This commit is contained in:
parent
e0a0030837
commit
badfb29ce1
22 changed files with 100 additions and 512 deletions
|
@ -23,15 +23,12 @@ import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
|||
import static google.registry.util.DateTimeUtils.latestOf;
|
||||
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||
import static google.registry.util.DateTimeUtils.leapSafeSubtractYears;
|
||||
import static google.registry.util.DateTimeUtils.toJodaDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toLocalDate;
|
||||
import static google.registry.util.DateTimeUtils.toSqlDate;
|
||||
import static google.registry.util.DateTimeUtils.toZonedDateTime;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.sql.Date;
|
||||
import java.time.ZonedDateTime;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -99,48 +96,6 @@ class DateTimeUtilsTest {
|
|||
assertThrows(IllegalArgumentException.class, () -> earliestOf(ImmutableList.of()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_toZonedDateTime_preservesTimeZone() {
|
||||
DateTime dateTime = DateTime.parse("2019-09-06T10:59:36.283-07:00"); // PDT
|
||||
ZonedDateTime zonedDateTime = toZonedDateTime(dateTime);
|
||||
assertThat(zonedDateTime.toString()).isEqualTo("2019-09-06T10:59:36.283-07:00"); // still PDT
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_toZonedDateTime_fromStringZulu() {
|
||||
DateTime dateTime = DateTime.parse("2015-10-13T11:22:33.168Z");
|
||||
ZonedDateTime zonedDateTime = toZonedDateTime(dateTime);
|
||||
assertThat(zonedDateTime.toString()).isEqualTo("2015-10-13T11:22:33.168Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_toZonedDateTime_leapYear() {
|
||||
DateTime dateTime = DateTime.parse("2016-02-29T11:22:33.168Z");
|
||||
ZonedDateTime zonedDateTime = toZonedDateTime(dateTime);
|
||||
assertThat(zonedDateTime.toString()).isEqualTo("2016-02-29T11:22:33.168Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_toJodaDateTime_preservesTimeZone() {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse("2019-09-06T10:59:36.283-07:00"); // PDT
|
||||
DateTime dateTime = toJodaDateTime(zonedDateTime);
|
||||
assertThat(dateTime.toString()).isEqualTo("2019-09-06T10:59:36.283-07:00"); // still PDT
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_toJodaDateTime_fromStringZulu() {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse("2015-10-13T11:22:33.168Z");
|
||||
DateTime dateTime = toJodaDateTime(zonedDateTime);
|
||||
assertThat(dateTime.toString()).isEqualTo("2015-10-13T11:22:33.168Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_toJodaDateTime_leapYear() {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse("2016-02-29T11:22:33.168Z");
|
||||
DateTime dateTime = toJodaDateTime(zonedDateTime);
|
||||
assertThat(dateTime.toString()).isEqualTo("2016-02-29T11:22:33.168Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_toSqlDate() {
|
||||
LocalDate localDate = LocalDate.parse("2020-02-29");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue