Search in sources :

Example 21 with TimeOfDay

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

the class TestPreciseDateTimeField 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 };
    BaseDateTimeField 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, 21, 0, 40 };
    result = field.add(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 23, 59, 30, 40 };
    try {
        field.add(new TimeOfDay(), 2, values, 30);
        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 22 with TimeOfDay

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

the class TestPreciseDateTimeField method test_set_RP_int_intarray_String_Locale.

public void test_set_RP_int_intarray_String_Locale() {
    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", 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, "60", 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, "-1", null);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    assertEquals(true, Arrays.equals(values, expected));
}
Also used : TimeOfDay(org.joda.time.TimeOfDay)

Example 23 with TimeOfDay

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

the class TestPreciseDurationDateTimeField 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 };
    BaseDateTimeField field = new MockStandardBaseDateTimeField();
    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, 21, 0, 40 };
    result = field.add(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(expected, result));
    values = new int[] { 23, 59, 30, 40 };
    try {
        field.add(new TimeOfDay(), 2, values, 30);
        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 24 with TimeOfDay

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

the class TestPreciseDurationDateTimeField method test_set_RP_int_intarray_int.

public void test_set_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDurationDateTimeField();
    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)

Example 25 with TimeOfDay

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

the class TestPreciseDurationDateTimeField method test_addWrapField_RP_int_intarray_int.

public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDurationDateTimeField();
    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)

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