@Test
  public void parseBasicWeekDate() throws ParseException {
    PlainTimestamp start = PlainTimestamp.of(2012, 4, 1, 14, 15);
    PlainTimestamp end = PlainTimestamp.of(2012, 4, 5, 16, 0);
    TimestampInterval expected = TimestampInterval.between(start, end);

    assertThat(TimestampInterval.parseISO("2012W137T1415/2012W144T1600"), is(expected));
  }
  @Test
  public void parseExtendedOrdinalDate() throws ParseException {
    PlainTimestamp start = PlainTimestamp.of(2012, 4, 1, 14, 15);
    PlainTimestamp end = PlainTimestamp.of(2012, 4, 5, 16, 0);
    TimestampInterval expected = TimestampInterval.between(start, end);

    assertThat(TimestampInterval.parseISO("2012-092T14:15/2012-096T16:00"), is(expected));
  }
  @Test
  public void parseAbbreviatedExtendedWeekDate() throws ParseException {
    PlainTimestamp start = PlainTimestamp.of(2012, 4, 1, 14, 15);
    PlainTimestamp end = PlainTimestamp.of(2012, 4, 5, 16, 0);
    TimestampInterval expected = TimestampInterval.between(start, end);

    assertThat(TimestampInterval.parseISO("2012-W13-7T14:15/W14-4T16:00"), is(expected));
  }
  @Test
  public void parseAbbreviatedWithoutDateOrT() throws ParseException {
    PlainTimestamp start = PlainTimestamp.of(2012, 4, 30, 14, 15);
    PlainTimestamp end = PlainTimestamp.of(2012, 4, 30, 16, 0);
    TimestampInterval expected = TimestampInterval.between(start, end);

    assertThat(TimestampInterval.parseISO("2012-04-30T14:15/16:00"), is(expected));
  }
  @Test
  public void parsePeriodAndExtendedWeekDate() throws ParseException {
    PlainTimestamp start = PlainTimestamp.of(2012, 4, 1, 14, 15);
    PlainTimestamp end = PlainTimestamp.of(2012, 4, 5, 16, 0);
    TimestampInterval expected = TimestampInterval.between(start, end);

    assertThat(TimestampInterval.parseISO("P0000-00-04T01:45/2012-W14-4T16:00"), is(expected));
  }
  @Test
  public void parsePeriodAndExtendedCalendarDate() throws ParseException {
    PlainTimestamp start = PlainTimestamp.of(2012, 4, 1, 14, 15);
    PlainTimestamp end = PlainTimestamp.of(2012, 4, 5, 16, 0);
    TimestampInterval expected = TimestampInterval.between(start, end);

    assertThat(TimestampInterval.parseISO("P4DT1H45M/2012-04-05T16:00"), is(expected));
  }
Ejemplo n.º 7
0
  @Test
  public void startAtMidnight() {
    Moment moment = PlainTimestamp.of(2015, 7, 17, 18, 1).atUTC();
    HijriCalendar hijri = HijriCalendar.ofUmalqura(1436, 10, 1);

    assertThat(hijri.atTime(18, 1).at(ZonalOffset.UTC, StartOfDay.MIDNIGHT), is(moment));
    assertThat(
        moment.toGeneralTimestamp(
            HijriCalendar.family(),
            HijriCalendar.VARIANT_UMALQURA,
            ZonalOffset.UTC,
            StartOfDay.MIDNIGHT),
        is(hijri.atTime(18, 1)));
  }
Ejemplo n.º 8
0
  @Test
  public void startInEvening() {
    Moment moment = PlainTimestamp.of(2015, 7, 17, 18, 1).atUTC();
    HijriCalendar hijri = HijriCalendar.ofUmalqura(1436, 10, 2);

    assertThat(hijri.atTime(18, 1).at(ZonalOffset.UTC, StartOfDay.EVENING), is(moment));
    GeneralTimestamp<HijriCalendar> tsp =
        moment.toGeneralTimestamp(
            HijriCalendar.family(),
            HijriCalendar.VARIANT_UMALQURA,
            ZonalOffset.UTC,
            StartOfDay.EVENING);
    assertThat(tsp.toDate(), is(hijri));
    assertThat(tsp.toTime(), is(PlainTime.of(18, 1)));
  }