code: public static String getHostnameFromFQDN(String fqdn) {
  		if (fqdn == null) {
  			throw new IllegalArgumentException("fqdn is null");
  		}
  		int dotPos = fqdn.indexOf('.');
  		if (dotPos == -1) {
  			return fqdn;
  		} else {
  			return fqdn.substring(0, dotPos);
  		}
  	}
docs: Turn a fully qualified domain name (fqdn) into a hostname. If the fqdn has multiple subparts
  (separated by a period '.'), it will take the first part. Otherwise it takes the entire fqdn.
  
  @param fqdn The fully qualified domain name.
  @return The hostname.