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