No matter where the negativity stems from, the power to resist and move above all the petty hostility lies solely in your hands. Here are a few ways you can address the issue and keep yourself safe from the pessimism, apart from harmonising the environment for yourself and others.
Recognise the source- Negativity often stems from gossip and rumors or misinformation and intentional assumptions. The most important part is to identify the reason of the bitterness, based on your own understanding and knowledge and not solely on hearsay and idle talk.
Talk it out- It can be surprising how much a mature conversation can help a sticky situation. Don't contribute to the negativity by succumbing to the bitterness and becoming defensive with your co-worker. Instead, talk it out. Listening is equally important. Sometimes people need a sounding board and your availability to help out might just help your co-worker.
State your case- The most affective tool to eliminate negativity is communication. Don't keep it bottled up. Let it out in a calm and confident manner. Confront the co-worker if things go out of hand without being aggressive or loud.
Steer clear- Even though communication is often helpful, sometimes the best thing is to keep your distance and your quiet. Remember that a negative colleague might just be out to gain attention and you getting involved will give him/her just that apart from making you a sourpuss. Maintaining a respectful distance is often the best thing.