Ejemplo n.º 1
1
  // -----------------------------------------------------------------------
  public void testDurationFields() {
    final GJChronology gj = GJChronology.getInstance();
    assertEquals("eras", gj.eras().getName());
    assertEquals("centuries", gj.centuries().getName());
    assertEquals("years", gj.years().getName());
    assertEquals("weekyears", gj.weekyears().getName());
    assertEquals("months", gj.months().getName());
    assertEquals("weeks", gj.weeks().getName());
    assertEquals("halfdays", gj.halfdays().getName());
    assertEquals("days", gj.days().getName());
    assertEquals("hours", gj.hours().getName());
    assertEquals("minutes", gj.minutes().getName());
    assertEquals("seconds", gj.seconds().getName());
    assertEquals("millis", gj.millis().getName());

    assertEquals(false, gj.eras().isSupported());
    assertEquals(true, gj.centuries().isSupported());
    assertEquals(true, gj.years().isSupported());
    assertEquals(true, gj.weekyears().isSupported());
    assertEquals(true, gj.months().isSupported());
    assertEquals(true, gj.weeks().isSupported());
    assertEquals(true, gj.days().isSupported());
    assertEquals(true, gj.halfdays().isSupported());
    assertEquals(true, gj.hours().isSupported());
    assertEquals(true, gj.minutes().isSupported());
    assertEquals(true, gj.seconds().isSupported());
    assertEquals(true, gj.millis().isSupported());

    assertEquals(false, gj.centuries().isPrecise());
    assertEquals(false, gj.years().isPrecise());
    assertEquals(false, gj.weekyears().isPrecise());
    assertEquals(false, gj.months().isPrecise());
    assertEquals(false, gj.weeks().isPrecise());
    assertEquals(false, gj.days().isPrecise());
    assertEquals(false, gj.halfdays().isPrecise());
    assertEquals(true, gj.hours().isPrecise());
    assertEquals(true, gj.minutes().isPrecise());
    assertEquals(true, gj.seconds().isPrecise());
    assertEquals(true, gj.millis().isPrecise());

    final GJChronology gjUTC = GJChronology.getInstanceUTC();
    assertEquals(false, gjUTC.centuries().isPrecise());
    assertEquals(false, gjUTC.years().isPrecise());
    assertEquals(false, gjUTC.weekyears().isPrecise());
    assertEquals(false, gjUTC.months().isPrecise());
    assertEquals(true, gjUTC.weeks().isPrecise());
    assertEquals(true, gjUTC.days().isPrecise());
    assertEquals(true, gjUTC.halfdays().isPrecise());
    assertEquals(true, gjUTC.hours().isPrecise());
    assertEquals(true, gjUTC.minutes().isPrecise());
    assertEquals(true, gjUTC.seconds().isPrecise());
    assertEquals(true, gjUTC.millis().isPrecise());

    final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
    final GJChronology gjGMT = GJChronology.getInstance(gmt);
    assertEquals(false, gjGMT.centuries().isPrecise());
    assertEquals(false, gjGMT.years().isPrecise());
    assertEquals(false, gjGMT.weekyears().isPrecise());
    assertEquals(false, gjGMT.months().isPrecise());
    assertEquals(true, gjGMT.weeks().isPrecise());
    assertEquals(true, gjGMT.days().isPrecise());
    assertEquals(true, gjGMT.halfdays().isPrecise());
    assertEquals(true, gjGMT.hours().isPrecise());
    assertEquals(true, gjGMT.minutes().isPrecise());
    assertEquals(true, gjGMT.seconds().isPrecise());
    assertEquals(true, gjGMT.millis().isPrecise());
  }
Ejemplo n.º 2
0
  public void testDateFields() {
    final GJChronology gj = GJChronology.getInstance();
    assertEquals("era", gj.era().getName());
    assertEquals("centuryOfEra", gj.centuryOfEra().getName());
    assertEquals("yearOfCentury", gj.yearOfCentury().getName());
    assertEquals("yearOfEra", gj.yearOfEra().getName());
    assertEquals("year", gj.year().getName());
    assertEquals("monthOfYear", gj.monthOfYear().getName());
    assertEquals("weekyearOfCentury", gj.weekyearOfCentury().getName());
    assertEquals("weekyear", gj.weekyear().getName());
    assertEquals("weekOfWeekyear", gj.weekOfWeekyear().getName());
    assertEquals("dayOfYear", gj.dayOfYear().getName());
    assertEquals("dayOfMonth", gj.dayOfMonth().getName());
    assertEquals("dayOfWeek", gj.dayOfWeek().getName());

    assertEquals(true, gj.era().isSupported());
    assertEquals(true, gj.centuryOfEra().isSupported());
    assertEquals(true, gj.yearOfCentury().isSupported());
    assertEquals(true, gj.yearOfEra().isSupported());
    assertEquals(true, gj.year().isSupported());
    assertEquals(true, gj.monthOfYear().isSupported());
    assertEquals(true, gj.weekyearOfCentury().isSupported());
    assertEquals(true, gj.weekyear().isSupported());
    assertEquals(true, gj.weekOfWeekyear().isSupported());
    assertEquals(true, gj.dayOfYear().isSupported());
    assertEquals(true, gj.dayOfMonth().isSupported());
    assertEquals(true, gj.dayOfWeek().isSupported());

    assertEquals(gj.eras(), gj.era().getDurationField());
    assertEquals(gj.centuries(), gj.centuryOfEra().getDurationField());
    assertEquals(gj.years(), gj.yearOfCentury().getDurationField());
    assertEquals(gj.years(), gj.yearOfEra().getDurationField());
    assertEquals(gj.years(), gj.year().getDurationField());
    assertEquals(gj.months(), gj.monthOfYear().getDurationField());
    assertEquals(gj.weekyears(), gj.weekyearOfCentury().getDurationField());
    assertEquals(gj.weekyears(), gj.weekyear().getDurationField());
    assertEquals(gj.weeks(), gj.weekOfWeekyear().getDurationField());
    assertEquals(gj.days(), gj.dayOfYear().getDurationField());
    assertEquals(gj.days(), gj.dayOfMonth().getDurationField());
    assertEquals(gj.days(), gj.dayOfWeek().getDurationField());

    assertEquals(null, gj.era().getRangeDurationField());
    assertEquals(gj.eras(), gj.centuryOfEra().getRangeDurationField());
    assertEquals(gj.centuries(), gj.yearOfCentury().getRangeDurationField());
    assertEquals(gj.eras(), gj.yearOfEra().getRangeDurationField());
    assertEquals(null, gj.year().getRangeDurationField());
    assertEquals(gj.years(), gj.monthOfYear().getRangeDurationField());
    assertEquals(gj.centuries(), gj.weekyearOfCentury().getRangeDurationField());
    assertEquals(null, gj.weekyear().getRangeDurationField());
    assertEquals(gj.weekyears(), gj.weekOfWeekyear().getRangeDurationField());
    assertEquals(gj.years(), gj.dayOfYear().getRangeDurationField());
    assertEquals(gj.months(), gj.dayOfMonth().getRangeDurationField());
    assertEquals(gj.weeks(), gj.dayOfWeek().getRangeDurationField());
  }