0

我必须访问当前系统并在 android 的 EditView 中显示。我正在使用此代码。请帮助我。

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

SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" ); 
editText.setText( sdf.format( new Date() ));
4

2 回答 2

1
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
                Date date = fmt.parse(Your date);
                editText.setText( date.toString());
于 2013-02-25T13:31:09.310 回答
0

如果要显示实际系统日期,请使用 Calendar 静态实例:

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

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    Date d = c.getTime();
    String date = sdf.format(d);
于 2013-02-25T13:33:47.967 回答