I'm trying to parse a date time object in Groovy running on Java 7 with strict/exact parsing.
I've tried using SimpleDateFormat
with setLenient
set to false
but it is still too lenient, e.g. parsing value 2018-8-2
with format yyyy-MM-dd
still succeeds (and returns the wrong date).
I came across a potential answer here: Java: How to parse a date strictly?
However the environment I'm working on does not allow me to invoke static methods for security reasons, preventing me from using Joda's
DateTimeFormat.forPattern("yyyy-MM-dd")
Given this restriction, how can I do an exact/strict parse of a DateTime string in Groovy?