public static String format(String mpackVersion) {
    Matcher m = PATTERN_FORMAT_VERSION.matcher(mpackVersion);
    if(m.matches()) {
      String majorVersion = m.group(1);
      String minorVersion = m.group(3);
      String maintVersion = m.group(5);
      String hotfixNum = m.group(7);
      String buildNum = m.group(9);
      if(hotfixNum != null || buildNum != null) {
        if(minorVersion == null || maintVersion == null) {
          // Both minorVersion and maintVersion should be specified
          throw new IllegalArgumentException("Wrong format for mpack version");
        }
      }
      minorVersion = minorVersion != null? minorVersion: "0";
      maintVersion = maintVersion != null? maintVersion: "0";
      hotfixNum = hotfixNum != null? hotfixNum: "0";
      buildNum = buildNum != null? buildNum: "0";
      String formattedMpackVersion = String.format("%s.%s.%s-h%s-b%s",
        majorVersion, minorVersion, maintVersion, hotfixNum, buildNum);
      return formattedMpackVersion;

    } else {
      throw new IllegalArgumentException("Wrong format for mpack version");
    }
  }
Method to format an mpack version in {major}.{minor}.{maint}-h{hotfix}-b{build} format
@param mpackVersion input mpack version string
@return formatted mpack version string
ambari-server/src/main/java/org/apache/ambari/server/utils/MpackVersion.java