use of org.joda.time.LocalTime in project osm-contributor by jawg.
the class OpeningMonthValueParserTest method nonStop1.
@Test
public void nonStop1() {
OpeningMonth openingMonth = new OpeningMonth();
OpeningHours openingHours = new OpeningHours();
openingHours.setDayActivated(0, true);
openingHours.setDayActivated(1, true);
openingHours.setDayActivated(2, true);
openingHours.setDayActivated(3, true);
openingHours.setDayActivated(4, true);
openingHours.setDayActivated(5, true);
openingHours.setDayActivated(6, true);
openingMonth.addOpeningHours(openingHours);
openingHours.setFromTime(new LocalTime(23, 59));
openingHours.setToTime(new LocalTime(23, 58));
Assert.assertEquals(parser.toValue(openingMonth), "24/7");
}
use of org.joda.time.LocalTime in project teiid by teiid.
the class ODataExecutionFactory method convertToODataInput.
public void convertToODataInput(Literal obj, StringBuilder sb) {
if (obj.getValue() == null) {
sb.append(NULL);
} else {
Class<?> type = obj.getType();
Object val = obj.getValue();
if (Number.class.isAssignableFrom(type)) {
sb.append(val);
} else if (type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
sb.append(obj.getValue().equals(Boolean.TRUE) ? true : false);
} else if (type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
LocalDateTime date = new LocalDateTime(val);
// $NON-NLS-1$
sb.append("datetime'").append(InternalUtil.formatDateTimeForXml(date)).append(// $NON-NLS-1$
"'");
} else if (type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
LocalTime time = new LocalTime(((java.sql.Time) val).getTime());
// $NON-NLS-1$
sb.append("time'").append(InternalUtil.formatTimeForXml(time)).append(// $NON-NLS-1$
"'");
} else if (type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
// $NON-NLS-1$
sb.append("date'").append(val).append(// $NON-NLS-1$
"'");
} else if (type.equals(DataTypeManager.DefaultDataClasses.VARBINARY)) {
// $NON-NLS-1$
sb.append("X'").append(val).append(// $NON-NLS-1$
"'");
} else {
sb.append(Tokens.QUOTE).append(escapeString(val.toString(), Tokens.QUOTE)).append(Tokens.QUOTE);
}
}
}
use of org.joda.time.LocalTime in project sql2o by aaberg.
the class OracleConverterTest method testLocalTimeConverter.
@Test
public void testLocalTimeConverter() throws ConverterException {
LocalTime lt = LocalTime.now();
TIMESTAMP oracleTime = new TIMESTAMP(new Timestamp(lt.toDateTimeToday().getMillis()));
LocalTime convertedTime = Convert.getConverterIfExists(LocalTime.class).convert(oracleTime);
assertEquals(lt, convertedTime);
}
use of org.joda.time.LocalTime in project sql2o by aaberg.
the class Sql2oTest method testTimeConverter.
@Test
public void testTimeConverter() {
String sql = "select current_time as col1 from (values(0))";
Time sqlTime = sql2o.createQuery(sql).executeScalar(Time.class);
Period p = new Period(new LocalTime(sqlTime), new LocalTime());
assertThat(sqlTime, is(notNullValue()));
assertTrue(p.getMinutes() == 0);
Date date = sql2o.createQuery(sql).executeScalar(Date.class);
assertThat(date, is(notNullValue()));
LocalTime jodaTime = sql2o.createQuery(sql).executeScalar(LocalTime.class);
assertTrue(jodaTime.getMillisOfDay() > 0);
assertThat(jodaTime.getHourOfDay(), is(equalTo(new LocalTime().getHourOfDay())));
}
use of org.joda.time.LocalTime in project uPortal by Jasig.
the class AggregationIntervalHelperImpl method getIntervalInfo.
@Override
public AggregationIntervalInfo getIntervalInfo(AggregationInterval interval, DateTime date) {
// Chop off everything below the minutes (seconds, millis)
final DateTime instant = date.minuteOfHour().roundFloorCopy();
final DateTime start, end;
switch(interval) {
case CALENDAR_QUARTER:
{
final List<QuarterDetail> quartersDetails = this.eventAggregationManagementDao.getQuartersDetails();
final QuarterDetail quarterDetail = EventDateTimeUtils.findDateRangeSorted(instant, quartersDetails);
start = quarterDetail.getStartDateMidnight(date).toDateTime();
end = quarterDetail.getEndDateMidnight(date).toDateTime();
break;
}
case ACADEMIC_TERM:
{
final List<AcademicTermDetail> academicTermDetails = this.eventAggregationManagementDao.getAcademicTermDetails();
final AcademicTermDetail academicTermDetail = EventDateTimeUtils.findDateRangeSorted(date, academicTermDetails);
if (academicTermDetail == null) {
return null;
}
start = academicTermDetail.getStart().toDateTime();
end = academicTermDetail.getEnd().toDateTime();
break;
}
default:
{
start = interval.determineStart(instant);
end = interval.determineEnd(start);
}
}
final LocalTime startTime = start.toLocalTime();
final TimeDimension startTimeDimension = this.timeDimensionDao.getTimeDimensionByTime(startTime);
final DateMidnight startDateMidnight = start.toDateMidnight();
final DateDimension startDateDimension = this.dateDimensionDao.getDateDimensionByDate(startDateMidnight);
return new AggregationIntervalInfo(interval, start, end, startDateDimension, startTimeDimension);
}
Aggregations