mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#578 - Deprecated Joda Time API - LocalDate.toDateMidnight() usage causes exception to be thrown, change to LocalDate.toDateTimeAtStartOfDay()
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.avaje.ebeaninternal.server.type;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class ScalarTypeJodaLocalDateTest {
|
||||
|
||||
ScalarTypeJodaLocalDate type = new ScalarTypeJodaLocalDate();
|
||||
|
||||
@Test
|
||||
public void convertToMillis_convertFromMillis() throws Exception {
|
||||
|
||||
LocalDate localDate = new LocalDate();
|
||||
long millis = type.convertToMillis(localDate);
|
||||
LocalDate localDate1 = type.convertFromMillis(millis);
|
||||
|
||||
assertThat(localDate).isEqualTo(localDate1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToDate_convertFromDate() throws Exception {
|
||||
|
||||
LocalDate localDate = new LocalDate();
|
||||
Date dateValue = type.convertToDate(localDate);
|
||||
LocalDate localDate1 = type.convertFromDate(dateValue);
|
||||
|
||||
assertThat(localDate).isEqualTo(localDate1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void toJdbcType() throws Exception {
|
||||
|
||||
LocalDate localDate = new LocalDate();
|
||||
Object jdbcType = type.toJdbcType(localDate);
|
||||
Date dateValue = type.convertToDate(localDate);
|
||||
|
||||
assertThat(jdbcType).isEqualTo(dateValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toBeanType() throws Exception {
|
||||
|
||||
LocalDate localDate = new LocalDate();
|
||||
Date dateValue = type.convertToDate(localDate);
|
||||
LocalDate beanType = type.toBeanType(dateValue);
|
||||
|
||||
assertThat(beanType).isEqualTo(localDate);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user