public static MpackVersion parseStackVersion(String stackVersion) {
    Matcher versionMatcher = validateStackVersion(stackVersion);

    if(versionMatcher.pattern().pattern().equals(LEGACY_STACK_VERSION_PATTERN)) {
      return new MpackVersion(Integer.parseInt(versionMatcher.group(1)),
        Integer.parseInt(versionMatcher.group(2)),
        Integer.parseInt(versionMatcher.group(3)), Integer.parseInt(versionMatcher.group(4)),
        Integer.parseInt(versionMatcher.group(5)));
    } else {
      throw new IllegalArgumentException("Wrong format for mpack version");
    }
  }
Method which will parse stack version
which user passed as parameter. Also
in this method version will be validated.
@param stackVersion string
@return MpackVersion instance which contains parsed version
ambari-server/src/main/java/org/apache/ambari/server/utils/MpackVersion.java