0

I have to access Current system and display in EditView in android.I am using this code.please help me.

EditText editText = (EditText) findViewById( R.id.your_edittext_id );

SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" ); 
editText.setText( sdf.format( new Date() ));
Chirag
  • 56,621
  • 29
  • 151
  • 198
Ravi
  • 31
  • 3

2 Answers2

1
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
                Date date = fmt.parse(Your date);
                editText.setText( date.toString());
Rohit
  • 3,401
  • 4
  • 33
  • 60
0

If you want to display actual system date, use Calendar static instance:

        Calendar c;
    c = Calendar.getInstance(TimeZone.getDefault());

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    Date d = c.getTime();
    String date = sdf.format(d);