Computing tax credit for taxes paid to NY by part year NJ resident

I was a resident of NY for 7 months and then moved to NJ.  i have 2 w2's from my employer. 1) w2 has my NY income and NY tax deducted.  2) has NJ income i.e for the 5 months wages earned in NY while resident of NJ.  The NJ W2 income is a double count as NY taxes have already been paid.   How do I determine taxes paid to NY for 5 months of wages?