Erasing the battery stats (for you rooters/flashers)
Sometimes you just want your phone to forget everything he thinks he knows about his battery, and re-learn it from scratch. Your phone maintains a file with statistics on battery usage, which in turn is used to help calculate battery life at any given time. Sometimes, especially if you've been playing with ROMs, kernels, and lagfixes, the stats in the file just aren't applicable anymore to how the hardware is being used, so you get crazy battery drain.
Clockwork Recovery has a simple function to wipe the battery stats. If you can't run Clockwork, use ADB or a terminal emulator (search the market) to delete that battery stats file located at /data/system/batterystats.bin. The link at the bottom to joeybear's thread has a little more info.
The general idea is to start by trying the above - make sure it isn't your own fault or maybe just a bad battery, then drain, bump charge, and wipe stats - in that order.
There are lots of ideas about what may or may not happen when you experiment with the above. Wiping battery stats after a ROM flash that already wiped them for you is at least redundant and may even contribute to a battery drain problem. Some say you should wipe first and then drain and bump charge. Be careful about wiping stats and bump charging too much, though. Over-charging your battery will hasten its demise.
HOWEVER, if you're like I was when I first started this thread, you've seen the above recommended many times, and none of it has ever helped you one bit with an actual sudden battery drain problem.
http://forum.xda-developers.com/showthread.php?t=765656