public static Pair<String,String> parseTitleAndDateInBrackets(String title){
  if (title == null)   return new Pair<>(null,null);
  Pattern p=Pattern.compile("(.*)\\s+\\(?([0-9]{4})\\)?",Pattern.CASE_INSENSITIVE);
  Matcher m=p.matcher(title);
  if (m.find()) {
    return new Pair<>(m.group(1),m.group(2));
  }
  return new Pair<>(title,null);
}

public static Pair < String , String > parseTitleAndDateInBrackets ( String title ) { if ( title == null ) return new Pair < > ( null , null ) ; Pattern p = Pattern . compile ( "(.*)\\s+\\(?([0-9]{4})\\)?" , Pattern . CASE_INSENSITIVE ) ; Matcher m = p . matcher ( title ) ; if ( m . find ( ) ) { return new Pair < > ( m . group ( 1 ) , m . group ( 2 ) ) ; } return new Pair < > ( title , null ) ; }
parses titles if they are in the form title ( year ) . the first element is the title , and the second element is the date , both can be null . if the matcher fails to find the pattern , then the passed in title is set as the first element , which is the title .
