Search in sources :

Example 76 with LocalDateTime

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"));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Chronology(org.joda.time.Chronology) GJChronology(org.joda.time.chrono.GJChronology) ISOChronology(org.joda.time.chrono.ISOChronology) BuddhistChronology(org.joda.time.chrono.BuddhistChronology)

Example 77 with LocalDateTime

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);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime) Test(org.junit.Test)

Example 78 with LocalDateTime

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));
    }
}
Also used : LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime) LocalTime(org.joda.time.LocalTime) BigInteger(java.math.BigInteger) LocalDateTime(org.joda.time.LocalDateTime) DateTime(org.joda.time.DateTime) LocalTime(org.joda.time.LocalTime) LocalDateTime(org.joda.time.LocalDateTime) URL(java.net.URL) Pair(com.mysema.commons.lang.Pair) BigDecimal(java.math.BigDecimal) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 79 with LocalDateTime

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;
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) HashMap(java.util.HashMap) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime) BigInteger(java.math.BigInteger)

Example 80 with LocalDateTime

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");
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Aggregations

LocalDateTime (org.joda.time.LocalDateTime)120 Test (org.junit.Test)73 Interval (org.joda.time.Interval)27 TimeframeInterval (de.avanux.smartapplianceenabler.schedule.TimeframeInterval)21 DateTime (org.joda.time.DateTime)18 TimeOfDay (de.avanux.smartapplianceenabler.schedule.TimeOfDay)17 Schedule (de.avanux.smartapplianceenabler.schedule.Schedule)12 LocalDate (org.joda.time.LocalDate)12 ArrayList (java.util.ArrayList)8 ConsecutiveDaysTimeframe (de.avanux.smartapplianceenabler.schedule.ConsecutiveDaysTimeframe)6 DayTimeframe (de.avanux.smartapplianceenabler.schedule.DayTimeframe)6 TimeOfDayOfWeek (de.avanux.smartapplianceenabler.schedule.TimeOfDayOfWeek)6 Date (java.util.Date)6 TestBuilder (de.avanux.smartapplianceenabler.test.TestBuilder)4 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)4 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)4 AccAccount (eu.bcvsolutions.idm.acc.entity.AccAccount)4 IdmAuthorizationPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto)4 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)4 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4