package ee.springdemo; import java.text.SimpleDateFormat; import java.util.Calendar; public class Logger { private String getDateTime() { return new SimpleDateFormat("yyyy.MM.dd HH:mm:ss").format(Calendar .getInstance().getTime()); } public void logIt() { System.out.println(getDateTime() + " Something happened"); } public void logItWithObject(Object object) { System.out.println(getDateTime() + " " + object.toString()); } public void logItAndDetectObject(Object object, String retVal) { if (object instanceof Player) { System.out.println(getDateTime() + " Instanceof Player, Object: " + object.toString() + " Name: " + retVal); return; } if (object instanceof Weapon) { System.out.println(getDateTime() + " Instanceof Weapon, Object: " + object.toString() + " Name: " + retVal); return; } System.out.println(getDateTime() + "Unknown instance, Object: " + object.toString()); } }