Search in sources :

Example 66 with LocalTime

use of org.joda.time.LocalTime in project cayenne by apache.

the class JodaModuleIT method testJodaLocalTime.

@Test
public void testJodaLocalTime() {
    ObjectContext context = runtime.newContext();
    LocalTimeTestEntity localTimeTestEntity = context.newObject(LocalTimeTestEntity.class);
    LocalTime localTime = LocalTime.now();
    localTimeTestEntity.setTime(localTime);
    context.commitChanges();
    LocalTimeTestEntity testRead = ObjectSelect.query(LocalTimeTestEntity.class).selectOne(context);
    LocalTime time = testRead.getTime();
    assertNotNull(time);
    assertEquals(LocalTime.class, time.getClass());
    assertEquals(localTime.getSecondOfMinute(), time.getSecondOfMinute());
    assertEquals(localTime.getMinuteOfHour(), time.getMinuteOfHour());
    assertEquals(localTime.getHourOfDay(), time.getHourOfDay());
}
Also used : LocalTime(org.joda.time.LocalTime) LocalTimeTestEntity(org.apache.cayenne.joda.db.LocalTimeTestEntity) ObjectContext(org.apache.cayenne.ObjectContext) Test(org.junit.Test)

Example 67 with LocalTime

use of org.joda.time.LocalTime in project cayenne by apache.

the class LocalTimeTypeTest method testMaterializeObjectTime.

public void testMaterializeObjectTime() throws Exception {
    Object o = type.materializeObject(resultSet(new Time(0)), 1, Types.TIME);
    assertEquals(new LocalTime(0), o);
}
Also used : LocalTime(org.joda.time.LocalTime) Time(java.sql.Time) LocalTime(org.joda.time.LocalTime)

Example 68 with LocalTime

use of org.joda.time.LocalTime in project beam by apache.

the class CivilTimeEncoder method decodePacked32TimeSeconds.

/**
 * Decodes {@code bitFieldTimeSeconds} as a {@link LocalTime} with seconds precision.
 *
 * <p>Encoding is as the following:
 *
 * <pre>
 *      3         2         1
 * MSB 10987654321098765432109876543210 LSB
 *                    | H ||  M ||  S |
 * </pre>
 *
 * @see #encodePacked32TimeSeconds(LocalTime)
 * @see #encodePacked32TimeSecondsAsJavaTime(int)
 */
// should return a java.time.LocalTime
@SuppressWarnings("GoodTime")
public static LocalTime decodePacked32TimeSeconds(int bitFieldTimeSeconds) {
    checkValidBitField(bitFieldTimeSeconds, TIME_SECONDS_MASK);
    int hourOfDay = getFieldFromBitField(bitFieldTimeSeconds, HOUR_MASK, HOUR_SHIFT);
    int minuteOfHour = getFieldFromBitField(bitFieldTimeSeconds, MINUTE_MASK, MINUTE_SHIFT);
    int secondOfMinute = getFieldFromBitField(bitFieldTimeSeconds, SECOND_MASK, SECOND_SHIFT);
    LocalTime time = new LocalTime(hourOfDay, minuteOfHour, secondOfMinute);
    checkValidTimeSeconds(time);
    return time;
}
Also used : LocalTime(org.joda.time.LocalTime)

Example 69 with LocalTime

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

the class TimedTaskSettingActivity method createDisposableTask.

private TimedTask createDisposableTask() {
    LocalTime time = TIME_FORMATTER.parseLocalTime(mDisposableTaskTime.getText().toString());
    LocalDate date = DATE_FORMATTER.parseLocalDate(mDisposableTaskDate.getText().toString());
    LocalDateTime dateTime = new LocalDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour());
    if (dateTime.isBefore(LocalDateTime.now())) {
        Toast.makeText(this, R.string.text_disposable_task_time_before_now, Toast.LENGTH_SHORT).show();
        return null;
    }
    return TimedTask.disposableTask(dateTime, mScriptFile.getPath(), ExecutionConfig.getDefault());
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) LocalTime(org.joda.time.LocalTime) LocalDate(org.joda.time.LocalDate)

Example 70 with LocalTime

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

the class LocalTimeCodecTest method should_parse_valid_formats.

@Test(groups = "unit", dataProvider = "LocalTimeCodecTest.parse")
public void should_parse_valid_formats(String input, LocalTime expected) {
    // when
    LocalTime actual = LocalTimeCodec.instance.parse(input);
    // then
    assertThat(actual).isEqualTo(expected);
}
Also used : LocalTime(org.joda.time.LocalTime) Test(org.testng.annotations.Test)

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