更新时间:2023-01-24 12:53:53
创建一个方法,如下面
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 "";
}
然后把它作为
And then call it as
tvDate.setText(formatDate(salesReportItems.getDate().toString()));
了解更多关于我如何可以更改日期格式java的