It can be kept for up to a year and still be good. Coffee has an unremarkable grassy flavor in the green state. The flavors we are familiar with develop during the roasting process. To bring out the best flavors of coffee, the roasting temperature must be closely monitored and adjusted during different stages of the process. There is an art and a science to coffee roasting.
Coffee loses weight as it roasts, as moisture and gasses are driven from the beans.
Since coffee is sold by the pound, some companies run shorter roasts producing lighter colored, more dense coffees. Less coffee goes up the chimney in smoke and more money goes into the roaster's pocket, but the flavor of the coffee is not properly developed. Single origin coffees lose some of their distinctive characteristics the longer and darker they are roasted. Over the last decade, we've seen the rise of large specialty coffee chains that offer nothing but dark roasts. Thus the chains have been able to produce a more consistent flavor profile, by muting some of the unique flavor components in their coffees.