use of org.joda.time.LocalDateTime in project joda-time by JodaOrg.
the class TestDateTimeFormatter method testParseLocalDateTime_monthDay_withDefaultYear_feb29.
public void testParseLocalDateTime_monthDay_withDefaultYear_feb29() {
Chronology chrono = GJChronology.getInstanceUTC();
DateTimeFormatter f = DateTimeFormat.forPattern("M d H m").withChronology(chrono).withLocale(Locale.UK).withDefaultYear(2012);
assertEquals(new LocalDateTime(2012, 2, 29, 13, 40, 0, 0, chrono), f.parseLocalDateTime("2 29 13 40"));
}
use of org.joda.time.LocalDateTime in project querydsl by querydsl.
the class LocalDateTimeTest method set.
@Test
public void set() throws SQLException {
LocalDateTime value = new LocalDateTime();
DateTime dt = value.toDateTime(DateTimeZone.UTC);
Timestamp ts = new Timestamp(dt.getMillis());
PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
stmt.setTimestamp(0, ts, UTC);
EasyMock.replay(stmt);
type.setValue(stmt, 0, value);
EasyMock.verify(stmt);
}
use of org.joda.time.LocalDateTime in project querydsl by querydsl.
the class TypeTest method test.
@SuppressWarnings("unchecked")
@Test
public void test() throws MalformedURLException, SQLException {
List<Pair<?, ?>> valueAndType = new ArrayList<Pair<?, ?>>();
valueAndType.add(Pair.of(new BigDecimal("1"), new BigDecimalType()));
valueAndType.add(Pair.of(new BigInteger("2"), new BigIntegerType()));
valueAndType.add(Pair.of(new BigDecimal("1.0"), new BigDecimalAsDoubleType()));
valueAndType.add(Pair.of(new BigInteger("2"), new BigIntegerAsLongType()));
//valueAndType.add(Pair.of(Boolean.TRUE, new BooleanType()));
valueAndType.add(Pair.of((byte) 1, new ByteType()));
valueAndType.add(Pair.of(new byte[0], new BytesType()));
valueAndType.add(Pair.of(Calendar.getInstance(), new CalendarType()));
valueAndType.add(Pair.of('c', new CharacterType()));
valueAndType.add(Pair.of(Currency.getInstance("EUR"), new CurrencyType()));
valueAndType.add(Pair.of(new java.sql.Date(0), new DateType()));
valueAndType.add(Pair.of(1.0, new DoubleType()));
valueAndType.add(Pair.of(1.0f, new FloatType()));
valueAndType.add(Pair.of(1, new IntegerType()));
valueAndType.add(Pair.of(true, new NumericBooleanType()));
valueAndType.add(Pair.of(1L, new LongType()));
valueAndType.add(Pair.of(new Object(), new ObjectType()));
valueAndType.add(Pair.of((short) 1, new ShortType()));
valueAndType.add(Pair.of("", new StringType()));
valueAndType.add(Pair.of(true, new TrueFalseType()));
valueAndType.add(Pair.of(true, new YesNoType()));
valueAndType.add(Pair.of(new Timestamp(0), new TimestampType()));
valueAndType.add(Pair.of(new Time(0), new TimeType()));
valueAndType.add(Pair.of(new URL("http://www.mysema.com"), new URLType()));
valueAndType.add(Pair.of(new java.util.Date(), new UtilDateType()));
valueAndType.add(Pair.of(new DateTime(), new DateTimeType()));
valueAndType.add(Pair.of(new LocalDateTime(), new LocalDateTimeType()));
valueAndType.add(Pair.of(new LocalDate(), new LocalDateType()));
valueAndType.add(Pair.of(new LocalTime(), new LocalTimeType()));
valueAndType.add(Pair.of(Gender.MALE, new EnumByNameType<Gender>(Gender.class)));
valueAndType.add(Pair.of(Gender.MALE, new EnumByOrdinalType<Gender>(Gender.class)));
valueAndType.add(Pair.of(EasyMock.createNiceMock(Blob.class), new BlobType()));
valueAndType.add(Pair.of(EasyMock.createNiceMock(Clob.class), new ClobType()));
valueAndType.add(Pair.of(UUID.randomUUID(), new UtilUUIDType(true)));
valueAndType.add(Pair.of(UUID.randomUUID(), new UtilUUIDType(false)));
for (Pair pair : valueAndType) {
value = null;
Type type = (Type) pair.getSecond();
assertNull(type.toString(), type.getValue(resultSet, 0));
type.setValue(statement, 0, pair.getFirst());
assertEquals(type.toString(), pair.getFirst(), type.getValue(resultSet, 0));
}
}
use of org.joda.time.LocalDateTime in project qi4j-sdk by Qi4j.
the class AbstractEntityStoreTest method createEntity.
protected TestEntity createEntity(UnitOfWork unitOfWork) throws UnitOfWorkCompletionException {
// Create entity
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder(TestEntity.class);
builder.instance().dateValue().set(new Date());
TestEntity instance = builder.newInstance();
instance.name().set("Test");
instance.intValue().set(42);
instance.longValue().set(42L);
instance.doubleValue().set(42D);
instance.floatValue().set(42F);
instance.booleanValue().set(Boolean.TRUE);
instance.bigIntegerValue().set(new BigInteger("42"));
instance.bigDecimalValue().set(new BigDecimal("42"));
instance.dateValue().set(new DateTime("2020-03-04T13:24:35", UTC).toDate());
instance.dateTimeValue().set(new DateTime("2020-03-04T13:24:35", UTC));
instance.localDateTimeValue().set(new LocalDateTime("2020-03-04T13:23:00"));
instance.localDateValue().set(new LocalDate("2020-03-04"));
instance.association().set(instance);
ValueBuilder<Tjabba> valueBuilder4 = module.newValueBuilder(Tjabba.class);
final Tjabba prototype4 = valueBuilder4.prototype();
prototype4.bling().set("BlinkLjus");
// Set value
ValueBuilder<TestValue2> valueBuilder2 = module.newValueBuilder(TestValue2.class);
TestValue2 prototype2 = valueBuilder2.prototype();
prototype2.stringValue().set("Bar");
Tjabba newValue = valueBuilder4.newInstance();
prototype2.anotherValue().set(newValue);
prototype2.anotherValue().set(newValue);
ValueBuilder<Tjabba> valueBuilder3 = module.newValueBuilder(Tjabba.class);
final Tjabba prototype3 = valueBuilder3.prototype();
prototype3.bling().set("Brakfis");
ValueBuilder<TestValue> valueBuilder1 = module.newValueBuilder(TestValue.class);
TestValue prototype = valueBuilder1.prototype();
prototype.enumProperty().set(TestEnum.VALUE3);
prototype.listProperty().get().add("Foo");
prototype.valueProperty().set(valueBuilder2.newInstance());
prototype.tjabbaProperty().set(valueBuilder3.newInstance());
Map<String, String> mapValue = new HashMap<>(1);
mapValue.put("foo", "bar");
prototype.mapStringStringProperty().set(mapValue);
instance.valueProperty().set(valueBuilder1.newInstance());
instance.manyAssociation().add(0, instance);
instance.namedAssociation().put("foo", instance);
instance.namedAssociation().put("bar", instance);
return instance;
}
use of org.joda.time.LocalDateTime in project qi4j-sdk by Qi4j.
the class AbstractQueryTest method script42_LocalDateTime.
@Test
public void script42_LocalDateTime() {
QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
Person person = templateFor(Person.class);
Query<Person> query = unitOfWork.newQuery(qb.where(ne(person.localDateTimeValue(), new LocalDateTime("2010-03-04T13:23:00", forID("CET")))));
System.out.println("*** script42_LocalDateTime: " + query);
verifyUnorderedResults(query, "Joe Doe");
}
Aggregations