Esempio n. 1
0
 /**
  * Parses a formatted string representing the frequency.
  *
  * <p>The format can either be based on ISO-8601, such as 'P3M' or without the 'P' prefix e.g.
  * '2W'.
  *
  * <p>The period must be positive and non-zero.
  *
  * @param toParse the string representing the frequency
  * @return the frequency
  * @throws IllegalArgumentException if the frequency cannot be parsed
  */
 @FromString
 public static Frequency parse(String toParse) {
   ArgChecker.notNull(toParse, "toParse");
   if (toParse.equalsIgnoreCase("Term")) {
     return TERM;
   }
   String prefixed = toParse.startsWith("P") ? toParse : "P" + toParse;
   try {
     return Frequency.of(Period.parse(prefixed));
   } catch (DateTimeParseException ex) {
     throw new IllegalArgumentException(ex);
   }
 }