Search in sources :

Example 61 with LocalTime

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");
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningMonth(io.jawg.osmcontributor.model.utils.OpeningMonth) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 62 with LocalTime

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);
        }
    }
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) LocalTime(org.joda.time.LocalTime) OSimpleObject(org.odata4j.core.OSimpleObject) LocalTime(org.joda.time.LocalTime) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime)

Example 63 with LocalTime

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

Example 64 with LocalTime

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

Example 65 with LocalTime

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);
}
Also used : LocalTime(org.joda.time.LocalTime) DateMidnight(org.joda.time.DateMidnight) ArrayList(java.util.ArrayList) List(java.util.List) DateTime(org.joda.time.DateTime)

Aggregations

LocalTime (org.joda.time.LocalTime)83 Test (org.junit.Test)34 OpeningHours (io.jawg.osmcontributor.model.utils.OpeningHours)17 LocalDate (org.joda.time.LocalDate)16 DateTime (org.joda.time.DateTime)15 LocalDateTime (org.joda.time.LocalDateTime)15 Date (java.util.Date)12 DateTimeZone (org.joda.time.DateTimeZone)10 OpeningMonth (io.jawg.osmcontributor.model.utils.OpeningMonth)6 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)6 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)5 OpeningTime (io.jawg.osmcontributor.model.utils.OpeningTime)4 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 ContentValues (android.content.ContentValues)2 Time (java.sql.Time)2 EntityManager (javax.persistence.EntityManager)2 EntityTransaction (javax.persistence.EntityTransaction)2 JodaSample3 (org.datanucleus.samples.types.jodatime.JodaSample3)2 DatePickerDialog (android.app.DatePickerDialog)1