While the other approaches listed here work, they are dependent on locale. I would prefer an approach that will work for anyone, anywhere, which you can do by comparing the month start to a known Sunday. For example:
["2017-01-06","2017-01-13","2017-01-20","2017-01-27"]
["2017-02-03","2017-02-10","2017-02-17","2017-02-24"]
["2017-03-03","2017-03-10","2017-03-17","2017-03-24","2017-03-31"]
["2017-04-07","2017-04-14","2017-04-21","2017-04-28"]
["2017-05-05","2017-05-12","2017-05-19","2017-05-26"]
["2017-06-02","2017-06-09","2017-06-16","2017-06-23","2017-06-30"]
["2017-07-07","2017-07-14","2017-07-21","2017-07-28"]
["2017-08-04","2017-08-11","2017-08-18","2017-08-25"]
["2017-09-01","2017-09-08","2017-09-15","2017-09-22","2017-09-29"]
["2017-10-06","2017-10-13","2017-10-20","2017-10-27"]
["2017-11-03","2017-11-09","2017-11-16","2017-11-23","2017-11-30"]
["2017-12-01","2017-12-08","2017-12-15","2017-12-22","2017-12-29"]
Best Answer
You just need to do some back-and-forth calculation to end up where you want.
N.B. This answer assumes that toStartOfWeek returns Sunday, which is not true for all locales. If you need to be concerned about international users, you'll have to determine if the locale starts on Sunday or Monday, which will determine if you need the addDays(1) at the end of the calculation.