Android - Custom Date style - SimpleDateFormat - app crash
<p>Im trying to make Statusbar date can change to an format gave by user though an inputbox</p>

<pre><code>&lt;PreferenceCategory android:title="StatusBar Date"&gt;
    &lt;CheckBoxPreference android:title="Custom date" android:key="custom_date" android:summary="Turn on to enable custom date format" android:defaultValue="false" /&gt;
    &lt;EditTextPreference android:title="Notification bar date format" android:key="custom_format" android:dependency="custom_date" /&gt;
&lt;/PreferenceCategory&gt;
</code></pre>

<p>I edit on smali code (i dont have source) and use dex2jar tool to convert smali to java command readable</p>

<pre><code>  private void updateSettings()
  {
    boolean bool;
    if (Settings.System.getInt(mContext.getContentResolver(), "custom_date", 1) != 1)
      bool = false;
    else
      bool = true;
    mCustomdate = bool;
  }

  private String getCustomDateformat()
  {
    return Settings.System.getString(mContext.getContentResolver(), "custom_format");
  }

  private final void updateClock()
  {
    Object localObject = new Date();
    getResources();
    if (!mCustomDate)
      localObject = android.text.format.DateFormat.getDateFormat(mContext).format((Date)localObject);
    else
      localObject = new SimpleDateFormat(getCustomDateformat()).format((Date)localObject);
    setText((CharSequence)localObject);
  }
</code></pre>

<p>Now if custom date option uncheck, my statusbar working normal with normal date format
If i choose custom date format, and put in a simple date format like "dd.MM.yy" and drag statusbar to see if it changed now my status bar crash</p>

<p>use Android Debug tool i have </p>

<pre><code>java.lang.NullPointerException

java.text.SimpleDateFormat.validatePattern(SimpleDateFormat.java:286)
</code></pre>

<p>I checked <strong>SimpleDateFormat.java</strong></p>

<pre><code>286        final int patternLength = template.length();
</code></pre>

<p>So what exactly wrong here?</p>
