Java Code Examples for org.joda.time.DateTime#toLocalDateTime()

The following examples show how to use org.joda.time.DateTime#toLocalDateTime() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void testMinAllowedValue() {
  long millis = validMinTime; // is in UTC from epoch (19710101)
  DateTime dateTime = new DateTime(millis, DateTimeZone.UTC);
  LocalDateTime localDateTime = dateTime.toLocalDateTime();
  int year = localDateTime.getYear();
  int month = localDateTime.getMonthOfYear();
  int day = localDateTime.getDayOfMonth();
  Assert.assertEquals(year, 1971);
  Assert.assertEquals(month, 1);
  Assert.assertEquals(day, 1);
}
 
Example 2
private Object getRandomValueForTimeColumn(boolean isSimpleDate, boolean isInvalidDate) {
  long randomMs = validMinTime + (long) (_random.nextDouble() * (startTime - validMinTime));
  Preconditions.checkArgument(TimeUtils.timeValueInValidRange(randomMs), "Value " + randomMs + " out of range");
  long dateColVal = randomMs;
  Object result;
  if (isInvalidDate) {
    result = new Long(new DateTime(2072, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC).getMillis());
    return result;
  } else if (isSimpleDate) {
    DateTime dateTime = new DateTime(randomMs, DateTimeZone.UTC);
    LocalDateTime localDateTime = dateTime.toLocalDateTime();
    int year = localDateTime.getYear();
    int month = localDateTime.getMonthOfYear();
    int day = localDateTime.getDayOfMonth();
    String dateColStr = String.format("%04d%02d%02d", year, month, day);
    dateColVal = Integer.valueOf(dateColStr);
    result = new Integer(Integer.valueOf(dateColStr));
  } else {
    result = new Long(dateColVal);
  }

  if (dateColVal < minTime) {
    minTime = dateColVal;
  }
  if (dateColVal > maxTime) {
    maxTime = dateColVal;
  }
  return result;
}
 
Example 3
@Override
public LocalDateTime fromNonNullValue(Timestamp value) {

    DateTime dateTime = new DateTime(value.getTime());
    LocalDateTime localDateTime = dateTime.toLocalDateTime();

    return localDateTime;
}
 
Example 4
@Override
public LocalDateTime convert(DateTime source) {
	return source.toLocalDateTime();
}
 
Example 5
@Override
public LocalDateTime convert(DateTime source) {
	return source.toLocalDateTime();
}
 
Example 6
@Override
public LocalDateTime convert(DateTime source) {
	return source.toLocalDateTime();
}
 
Example 7
@Override
public LocalDateTime convert(DateTime source) {
	return source.toLocalDateTime();
}
 
Example 8
@Override
protected Object[] toConvertedColumns(DateTime value) {

    return new Object[] { value.toLocalDateTime(), new DateTimeZoneWithOffset(value.getZone(), value.getZone().isFixed() ? null : DateTimeZone.forOffsetMillis(value.getZone().getOffset(value))) };
}
 
Example 9
@Override
protected Object[] toConvertedColumns(DateTime value) {
    return new Object[] { value.toLocalDateTime(), value.getZone() };
}
 
Example 10
@Override
protected Object[] toConvertedColumns(DateTime value) {

    return new Object[] { value.toLocalDateTime(), new DateTimeZoneWithOffset(value.getZone(), value.getZone().isFixed() ? null : DateTimeZone.forOffsetMillis(value.getZone().getOffset(value))) };
}
 
Example 11
@Override
protected Object[] toConvertedColumns(DateTime value) {
    return new Object[] { value.toLocalDateTime(), new DateTimeZoneWithOffset(value.getZone(), value.getZone().isFixed() ? null : DateTimeZone.forOffsetMillis(value.getZone().getOffset(value))) };
}