2013-02-25 34 views
0

我必須訪問當前的系統,並在Android的EditView中顯示我使用此code.please幫助我。訪問系統日期在Android的編輯視圖

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

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

點擊我的答案PLZ權象徵 – Rohit 2013-02-26 09:40:49

回答

1
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); 
       Date date = fmt.parse(Your date); 
       editText.setText(date.toString()); 
+0

感謝我result..through此代碼 – Ravi 2013-02-26 09:31:38

+0

@ Rohit請不要*要求人們投票/接受你的帖子。他們會,如果他們想。 – 2013-03-01 13:07:59

+0

@AndrewBarber,但他首先評論我的答案「謝謝」,那他爲什麼不接受答案? – Rohit 2013-03-01 13:10:47

0

如果你想顯示實際的系統日期,使用日曆靜態實例:

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

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