I want ot create a new instance of SimpleDateFormat with a pattern, which the user of the program gave. How do I know the pattern, given by the user, is a valid one ? Thanks. Alik
Hi Alik, Unless I am misinterpreting your question, what (I think) you need is the "applyPattern()" method (of class "java.text.SimpleDateFormat"). It throws an exception if the supplied pattern is invalid. Please check the javadocs for more details. Hope this has helped you. Good Luck, Avi.
Alik - look again. It throws IllegalArgumentException. Since this is a subclass of RuntimeException it's not required to be declared in a throws clause - but the javadoc does document it anyway, using the @exception tag. [ January 01, 2003: Message edited by: Jim Yingst ]
Sorry for not writting this earlier, but I'm using JDK 1.3.1. The method applyPattern() in JDK 1.3.1 does not throw an exception. Can you give a way to valid the pattern in JDK 1.3.1 ?