Search in sources :

Example 1 with TimeOfDay

use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.

the class TestGJChronology method testTimeOfDayAdd.

public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30, GJChronology.getInstance());
    TimeOfDay end = new TimeOfDay(10, 30, GJChronology.getInstance());
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 2 with TimeOfDay

use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.

the class TestISOChronology method testTimeOfDayAdd.

public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30);
    TimeOfDay end = new TimeOfDay(10, 30);
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 3 with TimeOfDay

use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.

the class TestDateConverter method testGetPartialValues.

//-----------------------------------------------------------------------
public void testGetPartialValues() throws Exception {
    TimeOfDay tod = new TimeOfDay();
    int[] expected = COPTIC.get(tod, 12345678L);
    int[] actual = DateConverter.INSTANCE.getPartialValues(tod, new Date(12345678L), COPTIC);
    assertEquals(true, Arrays.equals(expected, actual));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay) Date(java.util.Date)

Example 4 with TimeOfDay

use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.

the class TestOffsetDateTimeField method test_set_RP_int_intarray_int.

public void test_set_RP_int_intarray_int() {
    OffsetDateTimeField field = new MockOffsetDateTimeField();
    int[] values = new int[] { 10, 20, 30, 40 };
    int[] expected = new int[] { 10, 20, 30, 40 };
    int[] result = field.set(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 29, 40 };
    result = field.set(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 30, 40 };
    try {
        field.set(new TimeOfDay(), 2, values, 63);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    assertEquals(true, Arrays.equals(values, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 30, 40 };
    try {
        field.set(new TimeOfDay(), 2, values, 2);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    assertEquals(true, Arrays.equals(values, expected));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 5 with TimeOfDay

use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.

the class TestOffsetDateTimeField method test_set_RP_int_intarray_String_Locale.

public void test_set_RP_int_intarray_String_Locale() {
    OffsetDateTimeField field = new MockOffsetDateTimeField();
    int[] values = new int[] { 10, 20, 30, 40 };
    int[] expected = new int[] { 10, 20, 30, 40 };
    int[] result = field.set(new TimeOfDay(), 2, values, "30", null);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 29, 40 };
    result = field.set(new TimeOfDay(), 2, values, "29", Locale.ENGLISH);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 30, 40 };
    try {
        field.set(new TimeOfDay(), 2, values, "63", null);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    assertEquals(true, Arrays.equals(values, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 30, 40 };
    try {
        field.set(new TimeOfDay(), 2, values, "2", null);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    assertEquals(true, Arrays.equals(values, expected));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Aggregations

TimeOfDay (org.joda.time.TimeOfDay)25 Date (java.util.Date)2 GregorianCalendar (java.util.GregorianCalendar)1 Instant (org.joda.time.Instant)1 ReadableInstant (org.joda.time.ReadableInstant)1 YearMonthDay (org.joda.time.YearMonthDay)1