Siva K
Siva K

Reputation: 4968

date picker display problem in android

in my app i am trying to show a date picker in OnTouchEvent. When the date picker dialog appears it shows the Month in text such as May, June, July etc. When i select one among them it displays in numbers. I want it to be viewed as text itself. How to get it.....

Following is the part of my code

bd =(EditText)findViewById(R.id.dob);

final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);

private OnTouchListener bdListener = new View.OnTouchListener()
    {
      @Override
      public boolean onTouch(View v, MotionEvent event) 
      {
            showDialog(DATE_DIALOG_ID);
            return false;
      }
    };

private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() 
    {
      @Override
      public void onDateSet(DatePicker view, int year, int monthOfYear,int dayOfMonth) 
      {
         mYear = year;
         mMonth = monthOfYear;
         mDay = dayOfMonth;
         updateDisplay();
      }
    };

private void updateDisplay() 
    {
        bd.setText(new StringBuilder().append(mMonth+1).append("-").append(mDay).append("-").append(mYear));
    }

Upvotes: 1

Views: 919

Answers (1)

Greg McGowan
Greg McGowan

Reputation: 1360

So you have the month as an integer and you want the string representation.

I think you need DateFormatSymbols

monthText = new DateFormatSymbols().getMonths()[month];

Upvotes: 1

Related Questions