Agreed. The code available in e.g. Apache commons is not perfect, but it's seasoned and has the edge cases documented