I have an assignment I am working on for my class. In this assignment, I am asked to create the constructor and the get/set methods. I have done all of that EXCEPT in one of the classes, there are several attributes is listed which use "SimpleDateFormat" as a data type. In all my research, I've found SimpleDateFormat as a method, but not as a data type in itself (such as String or Boolean) and I don't see where it's been set up anywhere else except to import "import java.text.SimpleDateFormat;" into the class file. I cannot find anywhere that there's any kind of default format for this as a data type - I am brand new to Java of course so I amy be overlooking it, or missing something completely - but it's not being covered in my text in any way so I'm hoping you wonderful gurus can lend a hand and help point me in the right direction.
Here is the section of the attributes in the class file I was given for this assignment:
private SimpleDateFormat acquisitionDate;
private SimpleDateFormat statusDate;
private String acquisitionSource;
private Boolean reserved;
private String trainingLocation;
private SimpleDateFormat trainingStart;
private SimpleDateFormat trainingEnd;
private String trainingStatus;
Any help/insight is greatly appreciated!
SimpleDateFormatis a method, not a type?SimpleDateFormatandDate. Those classes are poorly designed and long outdated, the former in particular notoriously troublesome. Instead useDateTimeFormatterand other classes from java.time, the modern Java date and time API. You can tell your instructor the same if relevant.SimpleDateFormatwas a class just likeStringandBooleanare classes. And therefore also a type. It had got methods just like they have got methods. The difference is that it was a utility class, what Larman calls a pure fabrication, so not useful for holding domain data. Only in this way you are correct in not regarding it as a data type.