Custom class extends AppCompatActivity: getResources() is recognized by IDE, but Context is not available : <p>Can't figure out why my following code is broken</p>

<p>I've got MainActivity class:</p>

<pre><code>public class MainActivity implements PresenterListener {
...
private Presenter presenter = new Presenter(this);
...
}
</code></pre>

<p>Presenter:</p>

<pre><code>public class Presenter extends PresenterUtils {
    protected DateTimeFormatter dateFormat = DateTimeFormat.forPattern(getDateFormat());
}
</code></pre>

<p>PresenterUtils:</p>

<pre><code>public class PresenterUtils extends Utils {

    public String getDateFormat() {
        return getResources().getString(R.string.date_format);
    }
}
</code></pre>

<p>Utils extends AppCompatActivity, so context has to be available for this class. But its not. I mean, IDE allows me to apply <code>getResources()</code> method, but I've got an exception right after launching:</p>

<blockquote>
  <p>java.lang.RuntimeException: Unable to instantiate activity
  ComponentInfo{...} java.lang.NullPointerException: Attempt to invoke
  virtual method 'android.content.res.Resources
  android.content.Context.getResources()' on a null object reference</p>
</blockquote>

<p>Exception points to <code>getResources().getString(R.string.date_format)</code></p>

<p>But! If I apply application context</p>

<pre><code>public class PresenterUtils extends Utils {

    public String getDateFormat() {
        return ContextProvider.getContext().getResources().getString(R.string.date_format);
    }
}
</code></pre>

<p>where ContextProvider is</p>

<pre><code>public class ContextProvider extends Application {

    private static ContextProvider instance;

    public ContextProvider() {
        instance = this;
    }

    public static Context getContext() {
        return instance;
    }
}
</code></pre>

<p>everything is fine</p>

<p>Why is that?</p>
