Exemple #1
0
 /**
  * Creates a new <code>Years</code> by parsing a string in the ISO8601 format 'PnY'.
  *
  * <p>The parse will accept the full ISO syntax of PnYnMnWnDTnHnMnS however only the years
  * component may be non-zero. If any other component is non-zero, an exception will be thrown.
  *
  * @param periodStr the period string, null returns zero
  * @return the period in years
  * @throws IllegalArgumentException if the string format is invalid
  */
 public static Years parseYears(String periodStr) {
   if (periodStr == null) {
     return Years.ZERO;
   }
   Period p = PARSER.parsePeriod(periodStr);
   return Years.years(p.getYears());
 }