How do I convert an ACF field from a string to an integer?

First thing to fix is the_sub_field('year'), as it will print out your year string instead of passing it to your variable. Instead, I think you want

$year = get_sub_field('year');

And, to answer your question, it’s easy to convert a string to an int by passing (int) in front of the item.

$year = (int)get_sub_field('year');