예제 #1
0
  public void testIsSupported_DurationFieldType() {
    LocalTime test = new LocalTime(10, 20, 30, 40);
    assertEquals(true, test.isSupported(DurationFieldType.hours()));
    assertEquals(true, test.isSupported(DurationFieldType.minutes()));
    assertEquals(true, test.isSupported(DurationFieldType.seconds()));
    assertEquals(true, test.isSupported(DurationFieldType.millis()));
    assertEquals(true, test.isSupported(DurationFieldType.halfdays()));

    assertEquals(false, test.isSupported(DurationFieldType.days()));
    assertEquals(false, test.isSupported((DurationFieldType) null));
  }
예제 #2
0
  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));
  }