public static String getVersionSubstring(String version) {
    String[] versionParts = version.split("\\.");
    if (versionParts.length < 3) {
      throw  new IllegalArgumentException("Invalid version number");
    }

    return versionParts[0] + "." + versionParts[1] + "." + versionParts[2];
  }
Return N.N.N from N.N.N.xyz

@param version
         the version to extract the first three sections from.
@return the first three sections of the specified version.
ambari-server-spi/src/main/java/org/apache/ambari/server/utils/VersionUtils.java