code: public static Period parsePeriod(String string) {
  		string = string.trim();
  		if (string.startsWith("-P") || string.startsWith("P")) {
  			return Period.parse(string);
  		}
  		int years = 0, months = 0, days = 0;
  		Set<String> units = new HashSet<>();
  
  		Matcher matcher = PERIOD_PATTERN.matcher(string.trim().toLowerCase());
  		int lastEnd = 0;
  		while (!matcher.hitEnd()) {
  			if (!matcher.find() || matcher.start() != lastEnd) {
  				throw new IllegalArgumentException("Invalid period: " + string);
  			}
  			lastEnd = matcher.end();
  			String unit = matcher.group("unit");
  			if (!unit.endsWith("s")) {
  				unit += "s";
  			}
  			if (!units.add(unit)) {
  				throw new IllegalArgumentException("Time unit: " + unit + " occurs more than once.");
  			}
  			int result = Integer.parseInt(matcher.group("time"));
  			switch (unit) {
  				case "years":
  					years = result;
  					break;
  				case "months":
  					months = result;
  					break;
  				case "days":
  					days = result;
  					break;
  			}
  		}
  		return Period.of(years, months, days);
  	}
docs: Parses value to Period.
  1 year 2 months 3 days == Period.of(1, 2, 3)
  Every value can be negative, but you can't make all Period negative by negating year.
  In ISO format you can write -P1Y2M, which means -1 years -2 months in this format
  There can't be any spaces between '-' and DIGIT:
  -1  - Right
  - 2 - Wrong