#set($sdf = $spTools.getClass().forName(“java.text.SimpleDateFormat”).getInstance())
$sdf.getClass().getName()
This is trying to create an instance of SimpleDateFormat via Class.forName().getInstance()
Then you’re printing out the class name to see what it actually created.
Why the behavior might be strange:
getInstance() in Java does not necessarily return an instance of the base class. It often returns a subclass.
For example:
java.text.SimpleDateFormat.getInstance() → returns a pre-configured SimpleDateFormat object.
java.util.Calendar.getInstance() → returns an instance of GregorianCalendar.
java.util.TimeZone.getInstance() → returns the system’s default TimeZone, usually a subclass like sun.util.calendar.ZoneInfo (in Oracle JDK).