Use javascript: classList.contains
WebElement element = By.id("id");
String className = "hidden";
JavascriptExecutor js = (JavascriptExecutor) driver;
Boolean containsClass = js.executeScript("return arguments[0].classList.contains(arguments[1])", element, className);