Search in sources :

Example 21 with LocalTime

use of org.joda.time.LocalTime in project osm-contributor by jawg.

the class OpeningTimeValueParserTest method parseOpeningHours1.

@Test
public void parseOpeningHours1() {
    OpeningTime openingTime = new OpeningTime();
    OpeningMonth openingMonth = new OpeningMonth();
    OpeningHours openingHours1 = new OpeningHours();
    OpeningHours openingHours2 = new OpeningHours();
    openingMonth.addOpeningHours(openingHours1);
    openingMonth.addOpeningHours(openingHours2);
    openingMonth.setMonthActivated(2, true);
    openingHours1.setAllDaysActivated(false);
    openingHours1.setDayActivated(2, true);
    openingHours2.setAllDaysActivated(false);
    openingHours2.setDayActivated(5, true);
    openingHours2.setFromTime(new LocalTime(5, 30));
    openingHours2.setToTime(new LocalTime(17, 30));
    openingTime.addOpeningMonth(openingMonth);
    Assert.assertEquals(parser.toValue(openingTime), "Mar: We 08:00-18:00, Sa 05:30-17:30");
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningMonth(io.jawg.osmcontributor.model.utils.OpeningMonth) OpeningTime(io.jawg.osmcontributor.model.utils.OpeningTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 22 with LocalTime

use of org.joda.time.LocalTime in project osm-contributor by jawg.

the class OpeningTimeValueParserTest method fromValue1.

@Test
public void fromValue1() {
    String value = "Apr-May: Mo-Fr 10:15-01:30";
    OpeningTime openingTime = parser.fromValue(value);
    OpeningTime openingTimeExpected = new OpeningTime();
    OpeningMonth openingMonth = new OpeningMonth();
    openingTimeExpected.addOpeningMonth(openingMonth);
    openingMonth.setMonthActivated(3, true);
    openingMonth.setMonthActivated(4, true);
    OpeningHours openingHours = new OpeningHours();
    openingMonth.addOpeningHours(openingHours);
    openingHours.setFromTime(new LocalTime(10, 15));
    openingHours.setToTime(new LocalTime(1, 30));
    Assert.assertEquals(openingTimeExpected, openingTime);
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningMonth(io.jawg.osmcontributor.model.utils.OpeningMonth) OpeningTime(io.jawg.osmcontributor.model.utils.OpeningTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 23 with LocalTime

use of org.joda.time.LocalTime in project teiid by teiid.

the class ODataExecutionFactory method retrieveValue.

/**
 * @param value
 * @param expectedType
 * @return
 */
public Object retrieveValue(Object value, Class<?> expectedType) {
    if (value == null) {
        return null;
    }
    if (value instanceof LocalDateTime) {
        DateTime dateTime = ((LocalDateTime) value).toDateTime(DateTimeZone.forTimeZone(this.timeZone));
        return new java.sql.Timestamp(dateTime.getMillis());
    }
    if (value instanceof LocalTime) {
        return new java.sql.Timestamp(((LocalTime) value).toDateTimeToday().getMillis());
    }
    if (value instanceof UnsignedByte) {
        return Short.valueOf(((UnsignedByte) value).shortValue());
    }
    if (expectedType.isArray() && value instanceof OCollection<?>) {
        ArrayList<Object> result = new ArrayList<Object>();
        OCollection<?> arrayValues = (OCollection<?>) value;
        Iterator<?> it = arrayValues.iterator();
        while (it.hasNext()) {
            OSimpleObject<?> item = (OSimpleObject<?>) it.next();
            result.add(retrieveValue(item.getValue(), expectedType.getComponentType()));
        }
        Object target = java.lang.reflect.Array.newInstance(expectedType.getComponentType(), result.size());
        System.arraycopy(result.toArray(), 0, target, 0, result.size());
        value = target;
    }
    return value;
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) LocalTime(org.joda.time.LocalTime) OSimpleObject(org.odata4j.core.OSimpleObject) ArrayList(java.util.ArrayList) UnsignedByte(org.odata4j.core.UnsignedByte) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime) OCollection(org.odata4j.core.OCollection) OSimpleObject(org.odata4j.core.OSimpleObject)

Example 24 with LocalTime

use of org.joda.time.LocalTime in project java-driver by datastax.

the class JodaTimeCodecsTest method should_map_time_to_localtime.

/**
 * <p>
 * Validates that a <code>time</code> column can be mapped to a {@link LocalTime} by using
 * {@link LocalTimeCodec}.
 * </p>
 *
 * @test_category data_types:serialization
 * @expected_result properly maps.
 * @jira_ticket JAVA-846
 * @since 2.2.0
 */
@Test(groups = "short")
public void should_map_time_to_localtime() {
    // given
    LocalTime time = new LocalTime(12, 16, 34, 999);
    // when
    session().execute("insert into foo (c1, ctime) values (?, ?)", "should_map_time_to_localtime", time);
    ResultSet result = session().execute("select ctime from foo where c1=?", "should_map_time_to_localtime");
    // then
    assertThat(result.getAvailableWithoutFetching()).isEqualTo(1);
    Row row = result.one();
    assertThat(row.get("ctime", LocalTime.class)).isEqualTo(time);
    assertThat(row.getTime("ctime")).isEqualTo(NANOSECONDS.convert(time.getMillisOfDay(), MILLISECONDS));
}
Also used : LocalTime(org.joda.time.LocalTime) Test(org.testng.annotations.Test)

Example 25 with LocalTime

use of org.joda.time.LocalTime in project Auto.js by hyb1996.

the class TimedTask method getNextTime.

public long getNextTime() {
    if (isDisposable()) {
        return mMillis;
    }
    if (isDaily()) {
        LocalTime time = LocalTime.fromMillisOfDay(mMillis);
        long nextTimeMillis = time.toDateTimeToday().getMillis();
        if (System.currentTimeMillis() > nextTimeMillis) {
            return nextTimeMillis + TimeUnit.DAYS.toMillis(1);
        }
        return nextTimeMillis;
    }
    return getNextTimeOfWeeklyTask();
}
Also used : LocalTime(org.joda.time.LocalTime)

Aggregations

LocalTime (org.joda.time.LocalTime)81 Test (org.junit.Test)39 OpeningHours (io.jawg.osmcontributor.model.utils.OpeningHours)17 LocalDate (org.joda.time.LocalDate)14 DateTime (org.joda.time.DateTime)13 LocalDateTime (org.joda.time.LocalDateTime)13 Date (java.util.Date)11 DateTimeZone (org.joda.time.DateTimeZone)10 OpeningMonth (io.jawg.osmcontributor.model.utils.OpeningMonth)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 TimePickerDialog (android.app.TimePickerDialog)1