code: public static ReadablePeriod parsePeriodString(final String periodStr) {
      final ReadablePeriod period;
      final char periodUnit = periodStr.charAt(periodStr.length() - 1);
      if (periodStr.equals("null") || periodUnit == 'n') {
        return null;
      }
  
      final int periodInt =
          Integer.parseInt(periodStr.substring(0, periodStr.length() - 1));
      switch (periodUnit) {
        case 'y':
          period = Years.years(periodInt);
          break;
        case 'M':
          period = Months.months(periodInt);
          break;
        case 'w':
          period = Weeks.weeks(periodInt);
          break;
        case 'd':
          period = Days.days(periodInt);
          break;
        case 'h':
          period = Hours.hours(periodInt);
          break;
        case 'm':
          period = Minutes.minutes(periodInt);
          break;
        case 's':
          period = Seconds.seconds(periodInt);
          break;
        default:
          throw new IllegalArgumentException("Invalid schedule period unit '"
              + periodUnit);
      }
  
      return period;
    }
docs: Parse Period String to a ReadablePeriod Object
  
  @param periodStr string formatted period
  @return ReadablePeriod Object