You are bored when you don't have any real work to do. In most cases, it's a dangerous thing. Here is my take on it:
- Sometimes we like to think that there is nothing much to do at work, which is simply not true. There is a lot to be done and you should go have a chat with your manager/superior about it and find stuff to build.
- A good developer doesn't get bored frequently (can happen sometimes though) and usually finds work to do on their own.
- Developers can have downtimes too. Occasionally, they may not be willing to work (for whatever reason) and tend to believe that there isn't any real task left for them. It happens. The best thing to do is to take a day off, go for a small vacation and come back to work.
- If there is really nothing to do and you are bored, you should consider talking to your manager. Explain them that you are getting bored, and that you would like to build something meaningful. Think of the stuff you always wanted to build, but never got time. This is the right time to experiment with them. Your boss will be happy - trust me.
- After trying out the above, if you are still bored consider spending some time experimenting and learning new things on your own.
- If all else fails, and you are still bored, find a job where you will get a chance to work on something meaningful.
Hope this helps.