use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestReadableInstantConverter method testGetPartialValues.
//-----------------------------------------------------------------------
public void testGetPartialValues() throws Exception {
TimeOfDay tod = new TimeOfDay();
int[] expected = ISOChronology.getInstance().get(tod, 12345678L);
int[] actual = ReadableInstantConverter.INSTANCE.getPartialValues(tod, new Instant(12345678L), ISOChronology.getInstance());
assertEquals(true, Arrays.equals(expected, actual));
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestBaseDateTimeField method test_set_RP_int_intarray_int.
public void test_set_RP_int_intarray_int() {
BaseDateTimeField field = new MockBaseDateTimeField();
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));
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestBaseDateTimeField method test_addWrapField_RP_int_intarray_int.
public void test_addWrapField_RP_int_intarray_int() {
BaseDateTimeField field = new MockBaseDateTimeField();
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));
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestBaseDateTimeField 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) {
}
values = new int[] { 0, 0 };
try {
field.add(new MockPartial(), 0, values, 1000);
fail();
} catch (IllegalArgumentException ex) {
}
values = new int[] { 1, 0 };
try {
field.add(new MockPartial(), 0, values, -1000);
fail();
} catch (IllegalArgumentException ex) {
}
}
use of org.joda.time.TimeOfDay in project joda-time by JodaOrg.
the class TestBaseDateTimeField method test_set_RP_int_intarray_String_Locale.
public void test_set_RP_int_intarray_String_Locale() {
BaseDateTimeField field = new MockBaseDateTimeField();
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));
}
Aggregations