code: public static String anonymize(String ip) {
  		InetAddress inetAddress;
  		try {
  			inetAddress = InetAddresses.forString(ip);
  		} catch (IllegalArgumentException e) {
  			logger.warn(e.getMessage(), e);
  			inetAddress = null;
  		}
  		InetAddress anonymized = null;
  		if (inetAddress instanceof Inet4Address) {
  			anonymized = anonymizeIpV4Address((Inet4Address) inetAddress);
  		} else if (inetAddress instanceof Inet6Address) {
  			anonymized = anonymizeIpV6Address((Inet6Address) inetAddress);
  		}
  		if (anonymized != null) {
  			return anonymized.getHostAddress();
  		} else {
  			return null;
  		}
  	}
docs: Anonymizes IPv4 and IPv6 addresses
  <p>
  For IPv4 addresses, the last octet is set to zero. If the address is a IPv6 address, the last 80 bits (10 bytes)
  are set to zero.
  <p>
  This is just like Google Analytics handles IP anonymization: https://support.google.com/analytics/answer/2763052
  
  @param ip the full IPv4 or IPv6 address
  @return the anonymized IP address or null, if the provided ip address is invalid