Using Joda Date & Time API to parse multiple formats
I'm parsing third party log files containing date/time using Joda. The date/time is in one of two different formats, depending on the age of the log files I'm parsing. Currently I have code like this: try { return DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").parseDateTime(datePart); } catch (IllegalArgumentException e) { return DateTimeFormat.forPattern("E, MMM dd, yyyy HH:mm").parseDateTime(datePart); } This works but contravenes Joshua Bloch's advice from Effective Java 2nd Edition (Item 57: Use exceptions only for exceptional conditions). It also makes it hard to determine if an Illegal
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.