mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-12-01 15:37:14 +00:00
#1272 - ENH: Add built in support for Joda Period and java time Period
This commit is contained in:
1 parent
265bda8cf2
commit
75462e7410
5 files changed
+107
-5
No files matched your search
@@ -0,0 +1,42 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.Period;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ScalarTypePeriodTest {
|
||||
|
||||
private ScalarTypePeriod scalarType = new ScalarTypePeriod();
|
||||
|
||||
@Test
|
||||
public void getLength() {
|
||||
assertThat(scalarType.getLength()).isEqualTo(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatAndParse() {
|
||||
|
||||
Period original = Period.of(1,2, 4);
|
||||
|
||||
String value = scalarType.formatValue(original);
|
||||
assertThat(value).isEqualTo("P1Y2M4D");
|
||||
|
||||
Period period = scalarType.parse(value);
|
||||
assertThat(period).isEqualTo(original);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void convertFromDbString() {
|
||||
|
||||
Period original = Period.of(1, 2, 4);
|
||||
|
||||
String stringVal = scalarType.convertToDbString(original);
|
||||
Period period = scalarType.convertFromDbString(stringVal);
|
||||
|
||||
assertThat(period).isEqualTo(original);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user