Search in sources :

Example 6 with TimeOfDay

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

the class TestPreciseDurationDateTimeField method test_set_RP_int_intarray_String_Locale.

public void test_set_RP_int_intarray_String_Locale() {
    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", 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 7 with TimeOfDay

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

the class TestCalendarConverter method testGetPartialValues.

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

Example 8 with TimeOfDay

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

the class TestReadablePartialConverter method testGetPartialValues.

//-----------------------------------------------------------------------
public void testGetPartialValues() throws Exception {
    TimeOfDay tod = new TimeOfDay();
    int[] expected = new int[] { 1, 2, 3, 4 };
    int[] actual = ReadablePartialConverter.INSTANCE.getPartialValues(tod, new TimeOfDay(1, 2, 3, 4), ISOChronology.getInstance(PARIS));
    assertEquals(true, Arrays.equals(expected, actual));
    try {
        ReadablePartialConverter.INSTANCE.getPartialValues(tod, new YearMonthDay(2005, 6, 9), JULIAN);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    try {
        ReadablePartialConverter.INSTANCE.getPartialValues(tod, new MockTOD(), JULIAN);
        fail();
    } catch (IllegalArgumentException ex) {
    }
}
Also used : TimeOfDay(org.joda.time.TimeOfDay) YearMonthDay(org.joda.time.YearMonthDay)

Example 9 with TimeOfDay

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

the class TestLongConverter method testGetPartialValues.

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

Example 10 with TimeOfDay

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

the class TestNullConverter method testGetPartialValues.

//-----------------------------------------------------------------------
public void testGetPartialValues() throws Exception {
    TimeOfDay tod = new TimeOfDay();
    // now
    int[] expected = new int[] { 10 + 1, 20, 30, 40 };
    int[] actual = NullConverter.INSTANCE.getPartialValues(tod, null, ISOChronology.getInstance());
    assertEquals(true, Arrays.equals(expected, actual));
}
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