如何將2/3/2013
格式更改爲02/03/2013 (dd/mm/yyyy)
?datepicker和日曆中的日期格式更改
Calendar c1 = Calendar.getInstance();
year = c1.get(Calendar.YEAR);
month = c1.get(Calendar.MONTH);
day = c1.get(Calendar.DAY_OF_MONTH);
// formatter = new SimpleDateFormat("dd/MM/yyyy");
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
// set selected date into textview.
searchText.setText(new StringBuilder().append(month + 1).append("/").append(day).append("/").append(year).append(" "));
Log.i("DatePickerDialog","DatePickerDialog");
dpResult = (DatePicker) findViewById(R.id.dpResult);
// set selected date into datepicker also.
dpResult.init(year, month, day, null);
user.setSearchEntityType("ByDate");
}
};
電流輸出:
1/2/2013
d/m/y
尋找:
01/02/2013
dd/mm/yyyy
它以這種方式顯示[\t方法parseInt函數(INT)是未定義的類型新DatePickerDialog.OnDateSetListener(){}] – raki
看到我的編輯答案... –
我在相同的格式一樣。它將輸出爲49/51/2013任何事情我都改變searchText.setText(新的StringBuilder()。append(月+ 1).append(「/」)。append(day).append(「/」) .append(year).append(「」)); – raki