这是我的代码片段
此处日期为10-9月-2013 09:53:37格式
TextView tvDate = (TextView) convertView.findViewById(R.id.entered_date);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
tvDate.setText(dateFormat.format(salesReportItems.getDate().toString()));
TextView tvCardType = (TextView) convertView.findViewById(R.id.card_type);
tvCardType.setText(salesReportItems.getCardType().toString());请帮我整理一下这个issue.here是我的错误。

亲爱的Piyush,
下面是我使用您的代码时的输出

发布于 2013-09-11 05:52:08
创建如下方法
private String formatDate(String dateString) {
try {
SimpleDateFormat sd = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss" /* 10-Sep-2013 09:53:37*/);
Date d = sd.parse(dateString);
sd = new SimpleDateFormat("yyyy-MM-dd");
return sd.format(d);
} catch (ParseException e) {
}
return "";
}然后把它叫做
tvDate.setText(formatDate(salesReportItems.getDate().toString()));发布于 2013-09-11 05:34:35
试着像这样使用你的代码。
如果salesReportItems是Date类型的对象,那么..
String timeStamp = new SimpleDateFormat("yyyy-MM-dd")
.format(salesReportItems);
tvDate.setText(timeStamp);发布于 2013-09-11 05:39:50
我想这条线
tvDate.setText(dateFormat.format(salesReportItems.getDate().toString()));一定要像这样。
tvDate.setText(dateFormat.format(salesReportItems.getDate()));https://stackoverflow.com/questions/18733306
复制相似问题