code: private static MediaType parse(String mediaType) {
  
  		Assert.notNullOrEmptyTrimmed(mediaType, "Missing media type!");
  
  		String type = null;
  		String subType = null;
  		Map<String, String> params = new HashMap<>();
  
  		String[] parts = mediaType.split(";");
  		for (int i = 0; i < parts.length; i++) {
  
  			String part = StringUtils.trimToNull(parts[i]);
  			if (part == null) {
  				continue;
  			}
  
  			if (i == 0) {
  				// get type and subtype
  				String[] typeSubType = part.split("/");
  				Assert.isTrue(typeSubType.length == 2, "Missing or invalid type with subType: '" + part + "'");
  
  				type = StringUtils.trimToNull(typeSubType[0]);
  				subType = StringUtils.trimToNull(typeSubType[1]);
  
  				Assert.notNull(type, "Missing media type!");
  				Assert.notNull(subType, "Missing media sub-type!");
  
  			} else {
  
  				try {
  					Pair<String, String> pair = getNameValue(part);
  					params.put(pair.getKey(), pair.getValue());
  				}
  				catch (IllegalArgumentException e) {
  					log.warn("Invalid media type option: ", e);
  				}
  			}
  		}
  
  		return new MediaType(type, subType, params);
  	}
docs: Simple parsing utility to get MediaType
  
  @param mediaType to be parsed
  @return media type of throw IllegalArgumentException if parsing fails