After reading a bunch of open source code, I just found out that most of them are relying on Chesspresso which is a solid Java Chess library that can handle move validation, PGN parser (what I was looking for), chessboard renderering, etc.
The code is well-documented and easy to understand. It took me around 30 minutes to read the code and start testing. Pretty happy with this library.
You can download the source code from sourceforge: Chesspresso Source Code
Sample code: (This is a fragment from Game class, I just need to add more detail for the header section and I will be ready to dump each pgn game into my database).
public String getHeaderString(int line)
{
if (line == 0) {
StringBuffer sb = new StringBuffer();
sb.append(getWhite());
if (getWhiteElo() != 0) sb.append(" [").append(getWhiteElo()).append("]");
sb.append(" - ").append(getBlack());
if (getBlackElo() != 0) sb.append(" [").append(getBlackElo()).append("]");
sb.append(" ").append(getResultStr()).append(" (").append(getNumOfMoves()).append(")");
return sb.toString();
} else if (line == 1) {
StringBuffer sb = new StringBuffer();
sb.append(getEvent()).append(", ").append(getSite()).append(", ").append(getDate());
sb.append(" [").append(getRound()).append("]");
return sb.toString();
} else if (line == 2) {
return getECO();
} else {
throw new RuntimeException("Only 3 header lines supported");
}
}