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();
}
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();
}
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();
}
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);
}
};
}
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());
}
}
Aggregations