Q:

Working with Android Objects and Methods

I have a quick Android development question. I am working on an exercise and I have a class that gets the current date and time. The exercise wants me to try and format the date's text to something in a more readable human form. This is what I had which returned a date timestamp.
mDateButton.setText(getDate().toString());

So then to format the returned date to a more readable format this is what I did, with the help of a Google search.
mDateButton.setText(DateFormat.format("EEEE,  MMM d, yyyy", mCrime.getDate()).toString());

And it works, but my question is before getting the answer from a google search, how would I have known to put the DateFormat class before the returned value of my method for getDate(). I was putting it after the getDate() call. Is there some order I should be learning with OOP, because this is where I get stuck all the time.

A:

This is an example of the difference between class methods and instance methods.
format(CharSequence inFormat, Date inDate) is an example of a class method, technically called a "static method", which is why it is called on the DateFormat class.
getDate() is an example of an instance method, which is why it is called on the object mCrime (an instance of the Crime object).

