A man from Tonyrefail was sentenced to two years and four months in a Young Offenders Institute following his conviction.