public void testWithField_DateTimeFieldType_int_3() { LocalTime test = new LocalTime(10, 20, 30, 40); try { test.withField(DateTimeFieldType.dayOfMonth(), 6); fail(); } catch (IllegalArgumentException ex) { } }
public void testIsSupported_DateTimeFieldType() { LocalTime test = new LocalTime(10, 20, 30, 40); assertEquals(true, test.isSupported(DateTimeFieldType.hourOfDay())); assertEquals(true, test.isSupported(DateTimeFieldType.minuteOfHour())); assertEquals(true, test.isSupported(DateTimeFieldType.secondOfMinute())); assertEquals(true, test.isSupported(DateTimeFieldType.millisOfSecond())); assertEquals(true, test.isSupported(DateTimeFieldType.minuteOfDay())); assertEquals(true, test.isSupported(DateTimeFieldType.secondOfDay())); assertEquals(true, test.isSupported(DateTimeFieldType.millisOfDay())); assertEquals(true, test.isSupported(DateTimeFieldType.hourOfHalfday())); assertEquals(true, test.isSupported(DateTimeFieldType.halfdayOfDay())); assertEquals(true, test.isSupported(DateTimeFieldType.clockhourOfHalfday())); assertEquals(true, test.isSupported(DateTimeFieldType.clockhourOfDay())); assertEquals(false, test.isSupported(DateTimeFieldType.dayOfMonth())); assertEquals(false, test.isSupported((DateTimeFieldType) null)); DateTimeFieldType d = new DateTimeFieldType("hours") { private static final long serialVersionUID = 1L; public DurationFieldType getDurationType() { return DurationFieldType.hours(); } public DurationFieldType getRangeDurationType() { return null; } public DateTimeField getField(Chronology chronology) { return chronology.hourOfDay(); } }; assertEquals(false, test.isSupported(d)); d = new DateTimeFieldType("hourOfYear") { private static final long serialVersionUID = 1L; public DurationFieldType getDurationType() { return DurationFieldType.hours(); } public DurationFieldType getRangeDurationType() { return DurationFieldType.years(); } public DateTimeField getField(Chronology chronology) { return chronology.hourOfDay(); } }; assertEquals(false, test.isSupported(d)); }
// ----------------------------------------------------------------------- public void testGet_DateTimeFieldType() { LocalTime test = new LocalTime(10, 20, 30, 40); assertEquals(10, test.get(DateTimeFieldType.hourOfDay())); assertEquals(20, test.get(DateTimeFieldType.minuteOfHour())); assertEquals(30, test.get(DateTimeFieldType.secondOfMinute())); assertEquals(40, test.get(DateTimeFieldType.millisOfSecond())); assertEquals(TEST_TIME_NOW / 60000, test.get(DateTimeFieldType.minuteOfDay())); assertEquals(TEST_TIME_NOW / 1000, test.get(DateTimeFieldType.secondOfDay())); assertEquals(TEST_TIME_NOW, test.get(DateTimeFieldType.millisOfDay())); assertEquals(10, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(DateTimeConstants.AM, test.get(DateTimeFieldType.halfdayOfDay())); test = new LocalTime(12, 30); assertEquals(0, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(12, test.get(DateTimeFieldType.clockhourOfHalfday())); assertEquals(12, test.get(DateTimeFieldType.clockhourOfDay())); assertEquals(DateTimeConstants.PM, test.get(DateTimeFieldType.halfdayOfDay())); test = new LocalTime(14, 30); assertEquals(2, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(2, test.get(DateTimeFieldType.clockhourOfHalfday())); assertEquals(14, test.get(DateTimeFieldType.clockhourOfDay())); assertEquals(DateTimeConstants.PM, test.get(DateTimeFieldType.halfdayOfDay())); test = new LocalTime(0, 30); assertEquals(0, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(12, test.get(DateTimeFieldType.clockhourOfHalfday())); assertEquals(24, test.get(DateTimeFieldType.clockhourOfDay())); assertEquals(DateTimeConstants.AM, test.get(DateTimeFieldType.halfdayOfDay())); try { test.get(null); fail(); } catch (IllegalArgumentException ex) { } try { test.get(DateTimeFieldType.dayOfMonth()); fail(); } catch (IllegalArgumentException ex) { } }