use of java.time.LocalDateTime in project morphia by mongodb.
the class Java8EntityTest method queries.
@Test
public void queries() {
Instant instant = Instant.ofEpochMilli(System.currentTimeMillis());
LocalDate localDate = LocalDate.of(1995, 10, 15);
LocalDateTime localDateTime = LocalDateTime.of(2016, 4, 10, 14, 15, 16, 123 * 1000000);
LocalTime localTime = LocalTime.of(10, 29, 15, 848000000);
Java8Entity entity = createEntity(getDs(), instant, localDate, localDateTime, localTime);
compare(getDs(), entity, "instant", instant);
compare(getDs(), entity, "localDate", localDate);
compare(getDs(), entity, "localDateTime", localDateTime);
compare(getDs(), entity, "localTime", localTime);
}
use of java.time.LocalDateTime in project presto by prestodb.
the class TestJdbcQueryBuilder method setup.
@BeforeMethod
public void setup() throws SQLException {
database = new TestingDatabase();
jdbcClient = database.getJdbcClient();
columns = ImmutableList.of(new JdbcColumnHandle("test_id", "col_0", BIGINT), new JdbcColumnHandle("test_id", "col_1", DOUBLE), new JdbcColumnHandle("test_id", "col_2", BOOLEAN), new JdbcColumnHandle("test_id", "col_3", VARCHAR), new JdbcColumnHandle("test_id", "col_4", DATE), new JdbcColumnHandle("test_id", "col_5", TIME), new JdbcColumnHandle("test_id", "col_6", TIMESTAMP), new JdbcColumnHandle("test_id", "col_7", TINYINT), new JdbcColumnHandle("test_id", "col_8", SMALLINT), new JdbcColumnHandle("test_id", "col_9", INTEGER), new JdbcColumnHandle("test_id", "col_10", REAL));
Connection connection = database.getConnection();
try (PreparedStatement preparedStatement = connection.prepareStatement("create table \"test_table\" (" + "" + "\"col_0\" BIGINT, " + "\"col_1\" DOUBLE, " + "\"col_2\" BOOLEAN, " + "\"col_3\" VARCHAR(128), " + "\"col_4\" DATE, " + "\"col_5\" TIME, " + "\"col_6\" TIMESTAMP, " + "\"col_7\" TINYINT, " + "\"col_8\" SMALLINT, " + "\"col_9\" INTEGER, " + "\"col_10\" REAL " + ")")) {
preparedStatement.execute();
StringBuilder stringBuilder = new StringBuilder("insert into \"test_table\" values ");
int len = 1000;
LocalDateTime dateTime = LocalDateTime.of(2016, 3, 23, 12, 23, 37);
for (int i = 0; i < len; i++) {
stringBuilder.append(format(Locale.ENGLISH, "(%d, %f, %b, 'test_str_%d', '%s', '%s', '%s', %d, %d, %d, %f)", i, 200000.0 + i / 2.0, i % 2 == 0, i, Date.valueOf(dateTime.toLocalDate()), Time.valueOf(dateTime.toLocalTime()), Timestamp.valueOf(dateTime), i % 128, -i, i - 100, 100.0f + i));
dateTime = dateTime.plusHours(26);
if (i != len - 1) {
stringBuilder.append(",");
}
}
try (PreparedStatement preparedStatement2 = connection.prepareStatement(stringBuilder.toString())) {
preparedStatement2.execute();
}
}
}
use of java.time.LocalDateTime in project requery by requery.
the class TimeConversionsTest method testInsertReadDateTime.
@Test
public void testInsertReadDateTime() {
Event event = new Event();
UUID id = UUID.randomUUID();
LocalDateTime localDateTimeNow = LocalDateTime.now().withNano(0);
OffsetDateTime offsetDateTimeNow = OffsetDateTime.now(ZoneId.systemDefault()).withNano(0);
ZonedDateTime zonedDateTimeNow = ZonedDateTime.now(ZoneId.systemDefault()).withNano(0);
event.setId(id);
event.setLocalDateTime(localDateTimeNow);
event.setOffsetDateTime(offsetDateTimeNow);
event.setZonedDateTime(zonedDateTimeNow);
data.insert(event);
event = data.findByKey(Event.class, id);
Assert.assertEquals(localDateTimeNow, event.getLocalDateTime());
Assert.assertEquals(offsetDateTimeNow, event.getOffsetDateTime());
Assert.assertEquals(zonedDateTimeNow.toInstant(), event.getZonedDateTime().toInstant());
}
use of java.time.LocalDateTime in project spring-loaded by spring-projects.
the class Issue104 method run.
public static String run() {
LocalDateTime time = LocalDateTime.now();
ZonedDateTime zdt = time.atZone(ZoneId.systemDefault());
return zdt.toString();
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_plusDays_overYears.
@Test
public void test_plusDays_overYears() {
LocalDateTime t = LocalDateTime.of(2006, 7, 14, 12, 30, 40, 987654321).plusDays(366);
assertEquals(t, TEST_2007_07_15_12_30_40_987654321);
}
Aggregations