String dt=mDateButton.getText().toString();
String tm =mTimeButton.getText().toString();
try {
String format ="dd-MM-yyyy hh:mm a";
DateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
String v_date_str = dt + " " + tm;
// String setDate =sdf.format(dt + " " + tm);
Date v_date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH).parse(v_date_str );
DateFormat formatter = null;
formatter = new SimpleDateFormat("dd-MMM-yyyy");
Log.d("sset: ", ""+formatter.format(v_date));
} catch (ParseException e) {
e.printStackTrace();
}
注意:其中 dt = 2013-03-02 和 tm = 21:54 。但我在第 9 行遇到错误。我不知道是什么原因。请帮助我摆脱这个问题。先感谢您。