Tenor implements Comparable<Tenor>, Serializable { @FromString @SuppressWarnings("deprecation") public static Tenor parse(final String tenorStr) { ArgumentChecker.notNull(tenorStr, "tenorStr"); try { return new Tenor(DateUtils.toPeriod(tenorStr)); } catch (DateTimeParseException e) { return new Tenor(BusinessDayTenor.valueOf(tenorStr)); } } @Deprecated  Tenor(final Period period); private  Tenor(final BusinessDayTenor businessDayTenor); static Tenor of(final Period period); static Tenor of(final BusinessDayTenor businessDayTenor); @FromString @SuppressWarnings("deprecation") static Tenor parse(final String tenorStr); Period getPeriod(); BusinessDayTenor getBusinessDayTenor(); boolean isBusinessDayTenor(); static final Tenor ofDays(final int days); static final Tenor ofWeeks(final int weeks); static final Tenor ofMonths(final int months); static final Tenor ofYears(final int years); static final Tenor ofBusinessDay(final BusinessDayTenor businessDayTenor); static final Tenor ofBusinessDay(final String businessDayTenor); @ToString String toFormattedString(); @Override int compareTo(final Tenor other); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Deprecated
  static final Tenor OVERNIGHT; static final Tenor DAY; static final Tenor ONE_DAY; static final Tenor TWO_DAYS; static final Tenor THREE_DAYS; static final Tenor ONE_WEEK; static final Tenor TWO_WEEKS; static final Tenor THREE_WEEKS; static final Tenor SIX_WEEKS; static final Tenor ONE_MONTH; static final Tenor TWO_MONTHS; static final Tenor THREE_MONTHS; static final Tenor FOUR_MONTHS; static final Tenor FIVE_MONTHS; static final Tenor SIX_MONTHS; static final Tenor SEVEN_MONTHS; static final Tenor EIGHT_MONTHS; static final Tenor NINE_MONTHS; static final Tenor TEN_MONTHS; static final Tenor ELEVEN_MONTHS; static final Tenor TWELVE_MONTHS; static final Tenor EIGHTEEN_MONTHS; static final Tenor ONE_YEAR; static final Tenor TWO_YEARS; static final Tenor THREE_YEARS; static final Tenor FOUR_YEARS; static final Tenor FIVE_YEARS; static final Tenor SIX_YEARS; static final Tenor SEVEN_YEARS; static final Tenor EIGHT_YEARS; static final Tenor NINE_YEARS; static final Tenor TEN_YEARS; static final Tenor WORKING_WEEK; static final Tenor YEAR; static final Tenor LEAP_YEAR; static final Tenor ON; static final Tenor SN; static final Tenor TN; }
@Test(expectedExceptions = IllegalArgumentException.class) public void testParseFailure() { Tenor.parse("0D"); }
@Test public void testParsePeriod() { assertEquals(Tenor.TWO_DAYS, Tenor.parse("P2D")); assertEquals(Tenor.TWO_WEEKS, Tenor.parse("P14D")); assertEquals(Tenor.TWO_MONTHS, Tenor.parse("P2M")); assertEquals(Tenor.TWO_YEARS, Tenor.parse("P2Y")); }
@Test public void testParseBusinessDay() { assertEquals(Tenor.ON, Tenor.parse("OVERNIGHT")); assertEquals(Tenor.SN, Tenor.parse("SPOT_NEXT")); assertEquals(Tenor.TN, Tenor.parse("TOM_NEXT")); }