Hershey (HSY) - Get Report  shares trade ex-dividend Tuesday so you must buy now if you want to be one of those getting the dividend check after management finalizes its shareholder roster.

Hershey stock, at close to $91, is up 1.9% for the year so far compared with an S&P 500 down 6% for the period. However, Hershey is down 15% over the past 52 weeks while the S&P is down 8.4%. The Pennsylvania company operates in a packaged food industry that has struggled with weak profit margins and plummeting sales.

Hershey also faces a strong U.S. dollar that devalues its sales in overseas markets. Even with its relative outperformance the stock -- priced at 18 times forward earnings -- is valued at just one point higher than the S&P 500 index. Hershey's earnings growth is projected to accelerate, based on fiscal 2016 and fiscal 2017 consensus estimates of $4.35 a share and $4.64, respectively, so Hershey stock may still be undervalued.

But then there is that sweet 0.583 cent quarterly dividend, yielding 2.60% annually, 60 basis points higher than the average payer in the S&P 500 index. The company has raised its dividend more than 80% in the past five years. So Hershey is paying you to be patient as the company works on expanding its sales and profits.

The company is scheduled to send dividend payments on March 15 to shareholders of record as of Feb. 25. While this will mark the fourth straight quarter during which Hershey would have made the 0.583-cent payment, Hershey's profits have also risen thanks to the company raising the price of some of its products by some by 8%.

The pricing was evident in the company's fourth-quarter earnings beat. Hershey's earnings grew almost 8% year over year despite a 5% decline on revenue. So buy the stock, get the dividend and profit from the company's growth later.

This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.