Search in sources :

Example 1 with DateTime

use of org.joda.time.DateTime in project dropwizard by dropwizard.

the class GuavaJDBITest method sqlObjectsCanReturnJodaDateTime.

@Test
public void sqlObjectsCanReturnJodaDateTime() throws Exception {
    final GuavaPersonDAO dao = dbi.open(GuavaPersonDAO.class);
    final DateTime found = dao.getLatestCreatedAt(new DateTime(1365465077000L));
    assertThat(found).isNotNull();
    assertThat(found.getMillis()).isEqualTo(1365465078000L);
    assertThat(found).isEqualTo(new DateTime(1365465078000L));
    final DateTime notFound = dao.getCreatedAtByEmail("alice@example.org");
    assertThat(notFound).isNull();
    final Optional<DateTime> absentDateTime = dao.getCreatedAtByName("Alice Example");
    assertThat(absentDateTime).isNotNull();
    assertThat(absentDateTime.isPresent()).isFalse();
    final Optional<DateTime> presentDateTime = dao.getCreatedAtByName("Coda Hale");
    assertThat(presentDateTime).isNotNull();
    assertThat(presentDateTime.isPresent()).isTrue();
}
Also used : DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 2 with DateTime

use of org.joda.time.DateTime in project dropwizard by dropwizard.

the class JDBITest method sqlObjectsCanReturnJodaDateTime.

@Test
public void sqlObjectsCanReturnJodaDateTime() throws Exception {
    final PersonDAO dao = dbi.open(PersonDAO.class);
    final DateTime found = dao.getLatestCreatedAt(new DateTime(1365465077000L));
    assertThat(found).isNotNull();
    assertThat(found.getMillis()).isEqualTo(1365465078000L);
    assertThat(found).isEqualTo(new DateTime(1365465078000L));
    final DateTime notFound = dao.getCreatedAtByEmail("alice@example.org");
    assertThat(notFound).isNull();
    final Optional<DateTime> absentDateTime = dao.getCreatedAtByName("Alice Example");
    assertThat(absentDateTime).isNotNull();
    assertThat(absentDateTime.isPresent()).isFalse();
    final Optional<DateTime> presentDateTime = dao.getCreatedAtByName("Coda Hale");
    assertThat(presentDateTime).isNotNull();
    assertThat(presentDateTime.isPresent()).isTrue();
}
Also used : DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 3 with DateTime

use of org.joda.time.DateTime in project dropwizard by dropwizard.

the class JodaDateTimeMapperTest method mapColumnByName_TimestampIsNull.

@Test
public void mapColumnByName_TimestampIsNull() throws Exception {
    when(resultSet.getTimestamp("name")).thenReturn(null);
    DateTime actual = new JodaDateTimeMapper().mapColumn(resultSet, "name", null);
    assertThat(actual).isNull();
}
Also used : DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 4 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class DataSegment method bucketMonthComparator.

public static Comparator<DataSegment> bucketMonthComparator() {
    return new Comparator<DataSegment>() {

        @Override
        public int compare(DataSegment lhs, DataSegment rhs) {
            int retVal;
            DateTime lhsMonth = Granularities.MONTH.bucketStart(lhs.getInterval().getStart());
            DateTime rhsMonth = Granularities.MONTH.bucketStart(rhs.getInterval().getStart());
            retVal = lhsMonth.compareTo(rhsMonth);
            if (retVal != 0) {
                return retVal;
            }
            return lhs.compareTo(rhs);
        }
    };
}
Also used : DateTime(org.joda.time.DateTime) Comparator(java.util.Comparator)

Example 5 with DateTime

use of org.joda.time.DateTime in project druid by druid-io.

the class InputRowParserSerdeTest method testStringInputRowParserSerdeMultiCharset.

@Test
public void testStringInputRowParserSerdeMultiCharset() throws Exception {
    Charset[] testCharsets = { Charsets.US_ASCII, Charsets.ISO_8859_1, Charsets.UTF_8, Charsets.UTF_16BE, Charsets.UTF_16LE, Charsets.UTF_16 };
    for (Charset testCharset : testCharsets) {
        InputRow parsed = testCharsetParseHelper(testCharset);
        Assert.assertEquals(ImmutableList.of("foo", "bar"), parsed.getDimensions());
        Assert.assertEquals(ImmutableList.of("x"), parsed.getDimension("foo"));
        Assert.assertEquals(ImmutableList.of("y"), parsed.getDimension("bar"));
        Assert.assertEquals(new DateTime("3000").getMillis(), parsed.getTimestampFromEpoch());
    }
}
Also used : InputRow(io.druid.data.input.InputRow) Charset(java.nio.charset.Charset) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

DateTime (org.joda.time.DateTime)5683 Test (org.junit.Test)1667 Test (org.testng.annotations.Test)774 ArrayList (java.util.ArrayList)545 Date (java.util.Date)389 LocalDate (org.joda.time.LocalDate)374 DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)353 ResponseBody (okhttp3.ResponseBody)335 Interval (org.joda.time.Interval)307 Test (org.junit.jupiter.api.Test)281 HashMap (java.util.HashMap)272 BigDecimal (java.math.BigDecimal)234 DateTimeZone (org.joda.time.DateTimeZone)220 UUID (java.util.UUID)195 List (java.util.List)194 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)178 Map (java.util.Map)171 IOException (java.io.IOException)158 Result (io.druid.query.Result)153 ServiceCall (com.microsoft.rest.ServiceCall)148