code: public static Charset getCharset(String contentType)
      {
          if (contentType == null)
          {
              return UTF_8;
          }
  
          if (Constants.CTYPE_JSON_UTF8.equals(contentType))
          {
              return UTF_8; // Fast-track
          }
  
          Matcher matcher = CHARSET_PATT.matcher(contentType);
          if (matcher.find())
          {
              String encstr = matcher.group(1);
  
              if (encstr.equalsIgnoreCase("UTF-8"))
              {
                  return UTF_8; // Fast-track
              }
              else
              {
                  try
                  {
                      return Charset.forName(encstr.toUpperCase());
                  }
                  catch (Exception e)
                  {
                      // ignore //
                  }
              }
          }
  
          return ISO_8859_1;
      }
docs: Attempts to parse the {@link Charset} from a contentType string.
  
  If contentType is null or no charset declaration found, then UTF-8 is
  returned. If the found Charset declaration is unknown on this platform
  then a runtime exception is thrown.
  
  @param contentType
  @return a {@link Charset} parsed from a charset declaration in a
  {@code contentType} String.