Search in sources :

Example 16 with TimeOfDay

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

the class TestOffsetDateTimeField method test_add_RP_int_intarray_int.

public void test_add_RP_int_intarray_int() {
    int[] values = new int[] { 10, 20, 30, 40 };
    int[] expected = new int[] { 10, 20, 30, 40 };
    OffsetDateTimeField field = new MockStandardDateTimeField();
    int[] result = field.add(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 31, 40 };
    result = field.add(new TimeOfDay(), 2, values, 1);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 62, 40 };
    result = field.add(new TimeOfDay(), 2, values, 32);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 21, 3, 40 };
    result = field.add(new TimeOfDay(), 2, values, 33);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 23, 59, 30, 40 };
    try {
        field.add(new TimeOfDay(), 2, values, 33);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 29, 40 };
    result = field.add(new TimeOfDay(), 2, values, -1);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 19, 59, 40 };
    result = field.add(new TimeOfDay(), 2, values, -31);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 0, 0, 30, 40 };
    try {
        field.add(new TimeOfDay(), 2, values, -31);
        fail();
    } catch (IllegalArgumentException ex) {
    }
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 17 with TimeOfDay

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

the class TestOffsetDateTimeField method test_addWrapField_RP_int_intarray_int.

public void test_addWrapField_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.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 59, 40 };
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 3, 40 };
    result = field.addWrapField(new TimeOfDay(), 2, values, 33);
    assertEquals(true, Arrays.equals(result, expected));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 18 with TimeOfDay

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

the class TestPreciseDateTimeField method test_addWrapField_RP_int_intarray_int.

public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDateTimeField();
    int[] values = new int[] { 10, 20, 30, 40 };
    int[] expected = new int[] { 10, 20, 30, 40 };
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 59, 40 };
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 0, 40 };
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));
    values = new int[] { 10, 20, 30, 40 };
    expected = new int[] { 10, 20, 1, 40 };
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 19 with TimeOfDay

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

the class TestStringConverter method testGetPartialValues.

//-----------------------------------------------------------------------
public void testGetPartialValues() throws Exception {
    TimeOfDay tod = new TimeOfDay();
    int[] expected = new int[] { 3, 4, 5, 6 };
    int[] actual = StringConverter.INSTANCE.getPartialValues(tod, "T03:04:05.006", ISOChronology.getInstance());
    assertEquals(true, Arrays.equals(expected, actual));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 20 with TimeOfDay

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

the class TestPreciseDateTimeField method test_set_RP_int_intarray_int.

public void test_set_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDateTimeField();
    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, 60);
        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, -1);
        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