tentimes
tentimes

Reputation: 1462

Android studio DateFormat error - refuses to select android.text.format.DateFormat

I think this may be an Android studio bug and unfortunately it has stopped me in my tracks.

I am using (and selecting!) android.text.format.DateFormat as my DateFormat class, but I am getting an error: "Required: android.text.format.Dateformat, Found: java.text.DatefFormat") and it will not compile.

I am not importing or using java.text.DateFormat but Android Studio is insisting I am.

Here is the code:

package org.example.kev.criminalintent;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.text.format.DateFormat;

public class CrimeFragment extends Fragment {

    private Crime mCrime;
    private EditText mTitleField;
    private Button mDateButton;
    private CheckBox mSolvedCheckbox;
    private DateFormat dateFormat;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mCrime = new Crime();

        dateFormat = DateFormat.getLongDateFormat(this.getActivity());

    }

Upvotes: 1

Views: 847

Answers (1)

nasch
nasch

Reputation: 5498

For whatever reason, android.text.format.DateFormat.getLongDateFormat returns a java.text.DateFormat.

https://developer.android.com/reference/android/text/format/DateFormat.html#getLongDateFormat%28android.content.Context%29

Upvotes: 2

Related Questions