mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
WIP: Db migration alterColumn ...
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
package com.avaje.ebeaninternal.server.type;
|
||||
|
||||
import com.avaje.ebean.config.JsonConfig;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ScalarTypeJodaLocalDateTimeTest {
|
||||
|
||||
ScalarTypeJodaLocalDateTime type = new ScalarTypeJodaLocalDateTime(JsonConfig.DateTime.ISO8601);
|
||||
|
||||
@Test
|
||||
public void testConvertFromTimestamp() throws Exception {
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
Timestamp nowTs = new Timestamp(now);
|
||||
|
||||
LocalDateTime ldt1 = type.convertFromTimestamp(nowTs);
|
||||
LocalDateTime ldt2 = localConvertFromTimestamp(nowTs);
|
||||
|
||||
assertEquals(ldt1, ldt2);
|
||||
|
||||
Timestamp ts1 = type.convertToTimestamp(ldt1);
|
||||
Timestamp ts2 = localConvertToTimestamp(ldt2);
|
||||
|
||||
assertEquals(ts1, ts2);
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime localConvertFromTimestamp(Timestamp ts) {
|
||||
return new LocalDateTime(ts.getTime(), DateTimeZone.getDefault());
|
||||
}
|
||||
|
||||
|
||||
Timestamp localConvertToTimestamp(LocalDateTime t) {
|
||||
return new Timestamp(t.toDateTime(DateTimeZone.getDefault()).getMillis());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.avaje.ebeaninternal.server.type;
|
||||
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ScalarTypeJodaLocalTimeTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
//DateTimeZone timeZone = DateTimeZone.getDefault();
|
||||
//ISOChronology instance = ISOChronology.getInstance();
|
||||
|
||||
LocalDateTime ldt1 = new LocalDateTime(now, DateTimeZone.getDefault());
|
||||
LocalDateTime ldt2 = new LocalDateTime(now);
|
||||
|
||||
assertEquals(ldt1, ldt2);
|
||||
|
||||
Timestamp ts1 = new Timestamp(ldt1.toDateTime(DateTimeZone.getDefault()).getMillis());
|
||||
Timestamp ts2 = new Timestamp(ldt2.toDateTime().getMillis());
|
||||
|
||||
assertEquals(ts1, ts2);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user