This week's book giveaway is in the Java in General forum. We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line! See this thread for details.
Just throw an exception - it is by far the simplest thing to do. You might make that a custom extension of java.lang.RuntimeException and specifically catch that exception in the code that starts the parser - that way you can conveniently package the information found.
HOWEVER - I must point out a serious bug in your code. You simply can not rely on the characters method being called with the complete text to create a Date. It might work fine for some random amount of time and then fail. Depending on how the buffer loads that the SAX parser is reading fall in the stream of text, characters may get only part of the element contents.
Instead - when the startElement for the date is hit, begin accumulating characters input in a StringBuffer. When the endElement is hit you can look at the complete element contents.
It looks like you are on the right track to me but instead of a StringWriter you could use a StringBuilder(in Java 1.5 - slightly faster) or StringBuffer(in earlier Java).
Bill
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me: